MCPcopy Create free account
hub / github.com/Snapchat/Valdi / convertIndex

Method convertIndex

valdi_core/src/valdi_core/cpp/Utils/Marshaller.cpp:482–496  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

480}
481
482size_t Marshaller::convertIndex(int index) {
483 if (index >= 0) {
484 auto arrayIndex = static_cast<size_t>(index);
485 if (arrayIndex >= _stack.size()) {
486 return kInvalidIndex;
487 }
488 return arrayIndex;
489 } else {
490 auto offsetFromTop = static_cast<size_t>(-index);
491 if (offsetFromTop > _stack.size()) {
492 return kInvalidIndex;
493 }
494 return static_cast<size_t>(_stack.size() - offsetFromTop);
495 }
496}
497
498size_t Marshaller::convertIndexOrError(int index) {
499 auto resolvedIndex = convertIndex(index);

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected