MCPcopy Create free account
hub / github.com/CobaltFusion/DebugViewPP / AppendFromSelf

Method AppendFromSelf

Libraries/snappy/snappy.cc:1185–1218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1183 }
1184
1185 inline bool AppendFromSelf(size_t offset, size_t len) {
1186 char* op = op_;
1187 const size_t space_left = op_limit_ - op;
1188
1189 // Check if we try to append from before the start of the buffer.
1190 // Normally this would just be a check for "produced < offset",
1191 // but "produced <= offset - 1u" is equivalent for every case
1192 // except the one where offset==0, where the right side will wrap around
1193 // to a very big number. This is convenient, as offset==0 is another
1194 // invalid case that we also want to catch, so that we do not go
1195 // into an infinite loop.
1196 assert(op >= base_);
1197 size_t produced = op - base_;
1198 if (produced <= offset - 1u) {
1199 return false;
1200 }
1201 if (len <= 16 && offset >= 8 && space_left >= 16) {
1202 // Fast path, used for the majority (70-80%) of dynamic invocations.
1203 UnalignedCopy64(op - offset, op);
1204 UnalignedCopy64(op - offset + 8, op + 8);
1205 } else {
1206 if (space_left >= len + kMaxIncrementCopyOverflow) {
1207 IncrementalCopyFastPath(op - offset, op, len);
1208 } else {
1209 if (space_left < len) {
1210 return false;
1211 }
1212 IncrementalCopy(op - offset, op, len);
1213 }
1214 }
1215
1216 op_ = op + len;
1217 return true;
1218 }
1219};
1220
1221bool RawUncompress(const char* compressed, size_t n, char* uncompressed) {

Callers

nothing calls this directly

Calls 3

UnalignedCopy64Function · 0.85
IncrementalCopyFastPathFunction · 0.85
IncrementalCopyFunction · 0.85

Tested by

no test coverage detected