MCPcopy Create free account
hub / github.com/google/snappy / EmitCopy

Function EmitCopy

snappy.cc:701–729  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

699
700template <bool len_less_than_12>
701static inline char* EmitCopy(char* op, size_t offset, size_t len) {
702 assert(len_less_than_12 == (len < 12));
703 if (len_less_than_12) {
704 return EmitCopyAtMost64</*len_less_than_12=*/true>(op, offset, len);
705 } else {
706 // A special case for len <= 64 might help, but so far measurements suggest
707 // it's in the noise.
708
709 // Emit 64 byte copies but make sure to keep at least four bytes reserved.
710 while (SNAPPY_PREDICT_FALSE(len >= 68)) {
711 op = EmitCopyAtMost64</*len_less_than_12=*/false>(op, offset, 64);
712 len -= 64;
713 }
714
715 // One or two copies will now finish the job.
716 if (len > 64) {
717 op = EmitCopyAtMost64</*len_less_than_12=*/false>(op, offset, 60);
718 len -= 60;
719 }
720
721 // Emit remainder.
722 if (len < 12) {
723 op = EmitCopyAtMost64</*len_less_than_12=*/true>(op, offset, len);
724 } else {
725 op = EmitCopyAtMost64</*len_less_than_12=*/false>(op, offset, len);
726 }
727 return op;
728 }
729}
730
731bool GetUncompressedLength(const char* start, size_t n, size_t* result) {
732 uint32_t v = 0;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected