MCPcopy Create free account
hub / github.com/apache/fory / readVarUInt64Value

Method readVarUInt64Value

javascript/packages/core/lib/reader/index.ts:493–556  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

491 }
492
493 private readVarUInt64Value(): number | bigint {
494 // Keep values in number form until the public bigint boundary. This avoids
495 // per-byte BigInt work for the common safe-int64 range.
496 const cursor = this.cursor;
497 if (this.byteLength - cursor < 8) {
498 return this.readVarUInt64SlowNumber();
499 }
500 const l32 = this.dataView.getUint32(cursor, true);
501 let byte = l32 & 0xff;
502 let rl28 = byte & 0x7f;
503 let rh28 = 0;
504
505 if ((byte & 0x80) === 0) {
506 this.cursor = cursor + 1;
507 return rl28;
508 }
509 byte = (l32 >>> 8) & 0xff;
510 rl28 |= (byte & 0x7f) << 7;
511 if ((byte & 0x80) === 0) {
512 this.cursor = cursor + 2;
513 return rl28;
514 }
515 byte = (l32 >>> 16) & 0xff;
516 rl28 |= (byte & 0x7f) << 14;
517 if ((byte & 0x80) === 0) {
518 this.cursor = cursor + 3;
519 return rl28;
520 }
521 byte = l32 >>> 24;
522 rl28 |= (byte & 0x7f) << 21;
523 if ((byte & 0x80) === 0) {
524 this.cursor = cursor + 4;
525 return rl28;
526 }
527
528 const h32 = this.dataView.getUint32(cursor + 4, true);
529 byte = h32 & 0xff;
530 rh28 = byte & 0x7f;
531 if ((byte & 0x80) === 0) {
532 this.cursor = cursor + 5;
533 return this.finishVarUInt64(rl28, rh28);
534 }
535 byte = (h32 >>> 8) & 0xff;
536 rh28 |= (byte & 0x7f) << 7;
537 if ((byte & 0x80) === 0) {
538 this.cursor = cursor + 6;
539 return this.finishVarUInt64(rl28, rh28);
540 }
541 byte = (h32 >>> 16) & 0xff;
542 rh28 |= (byte & 0x7f) << 14;
543 if ((byte & 0x80) === 0) {
544 this.cursor = cursor + 7;
545 return this.finishVarUInt64(rl28, rh28);
546 }
547 byte = h32 >>> 24;
548 rh28 |= (byte & 0x7f) << 21;
549 if ((byte & 0x80) === 0) {
550 this.cursor = cursor + 8;

Callers 2

readVarUInt64Method · 0.95
readVarInt64Method · 0.95

Calls 2

finishVarUInt64Method · 0.95

Tested by

no test coverage detected