MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / WriteSignedNumIncreasing

Method WriteSignedNumIncreasing

tensorflow/core/lib/strings/ordered_code.cc:466–486  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

464}
465
466void OrderedCode::WriteSignedNumIncreasing(string* dest, int64 val) {
467 const uint64 x = val < 0 ? ~val : val;
468 if (x < 64) { // fast path for encoding length == 1
469 *dest += kLengthToHeaderBits[1][0] ^ val;
470 return;
471 }
472 // buf = val in network byte order, sign extended to 10 bytes
473 const char sign_byte = val < 0 ? '\xff' : '\0';
474 char buf[10] = {
475 sign_byte,
476 sign_byte,
477 };
478 StoreBigEndian64(buf + 2, val);
479 static_assert(sizeof(buf) == kMaxSigned64Length, "max length size mismatch");
480 const int len = SignedEncodingLength(x);
481 DCHECK_GE(len, 2);
482 char* const begin = buf + sizeof(buf) - len;
483 begin[0] ^= kLengthToHeaderBits[len][0];
484 begin[1] ^= kLengthToHeaderBits[len][1]; // ok because len >= 2
485 dest->append(begin, len);
486}
487
488bool OrderedCode::ReadSignedNumIncreasing(StringPiece* src, int64* result) {
489 if (src->empty()) return false;

Callers

nothing calls this directly

Calls 3

StoreBigEndian64Function · 0.85
SignedEncodingLengthFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected