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

Function ConsumeLeadingDigits

tensorflow/core/platform/str_util.cc:63–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63bool ConsumeLeadingDigits(StringPiece* s, uint64* val) {
64 const char* p = s->data();
65 const char* limit = p + s->size();
66 uint64 v = 0;
67 while (p < limit) {
68 const char c = *p;
69 if (c < '0' || c > '9') break;
70 uint64 new_v = (v * 10) + (c - '0');
71 if (new_v / 8 < v) {
72 // Overflow occurred
73 return false;
74 }
75 v = new_v;
76 p++;
77 }
78 if (p > s->data()) {
79 // Consume some digits
80 s->remove_prefix(p - s->data());
81 *val = v;
82 return true;
83 } else {
84 return false;
85 }
86}
87
88bool ConsumeNonWhitespace(StringPiece* s, StringPiece* val) {
89 const char* p = s->data();

Callers 3

TestConsumeLeadingDigitsFunction · 0.85
ConsumeNumberFunction · 0.85
TESTFunction · 0.85

Calls 2

dataMethod · 0.45
sizeMethod · 0.45

Tested by 2

TestConsumeLeadingDigitsFunction · 0.68
TESTFunction · 0.68