diff options
author | 2016-01-18 19:37:50 -0800 | |
---|---|---|
committer | 2016-01-19 07:31:45 -0800 | |
commit | 8a1c308450b64a7d3c2ca520109c4909acbf13ff (patch) | |
tree | 3bee1c9e4e9cb69c83abf0ce010c19537dfc14be /tensorflow/core/lib/strings/str_util.cc | |
parent | 8a445e54b893f313ca44c7ef124b1884f4994e95 (diff) |
Remove word2vec's dependency on RE2. This is primarily to allow inputs
over 2GiB in size.
As part of this, add ConsumeNonWhitespace() to str_util.
Change: 112436569
Diffstat (limited to 'tensorflow/core/lib/strings/str_util.cc')
-rw-r--r-- | tensorflow/core/lib/strings/str_util.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tensorflow/core/lib/strings/str_util.cc b/tensorflow/core/lib/strings/str_util.cc index 562a2cfb1d..5a6a888d3f 100644 --- a/tensorflow/core/lib/strings/str_util.cc +++ b/tensorflow/core/lib/strings/str_util.cc @@ -311,6 +311,25 @@ bool ConsumeLeadingDigits(StringPiece* s, uint64* val) { } } +bool ConsumeNonWhitespace(StringPiece* s, StringPiece* val) { + const char* p = s->data(); + const char* limit = p + s->size(); + while (p < limit) { + const char c = *p; + if (isspace(c)) break; + p++; + } + const size_t n = p - s->data(); + if (n > 0) { + val->set(s->data(), n); + s->remove_prefix(n); + return true; + } else { + val->clear(); + return false; + } +} + bool SplitAndParseAsInts(StringPiece text, char delim, std::vector<int32>* result) { result->clear(); |