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

Method ReadLine

tensorflow/core/lib/io/inputbuffer.cc:45–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45Status InputBuffer::ReadLine(string* result) {
46 result->clear();
47 Status s;
48 do {
49 size_t buf_remain = limit_ - pos_;
50 char* newline = static_cast<char*>(memchr(pos_, '\n', buf_remain));
51 if (newline != nullptr) {
52 size_t result_len = newline - pos_;
53 result->append(pos_, result_len);
54 pos_ = newline + 1;
55 if (!result->empty() && result->back() == '\r') {
56 result->resize(result->size() - 1);
57 }
58 return Status::OK();
59 }
60 if (buf_remain > 0) result->append(pos_, buf_remain);
61 // Get more data into buffer
62 s = FillBuffer();
63 DCHECK_EQ(pos_, buf_);
64 } while (limit_ != buf_);
65 if (!result->empty() && result->back() == '\r') {
66 result->resize(result->size() - 1);
67 }
68 if (errors::IsOutOfRange(s) && !result->empty()) {
69 return Status::OK();
70 }
71 return s;
72}
73
74Status InputBuffer::ReadNBytes(int64 bytes_to_read, string* result) {
75 result->clear();

Callers 11

ReadOpListFromFileFunction · 0.45
ReadAllLinesMethod · 0.45
mainFunction · 0.45
TESTFunction · 0.45
TESTFunction · 0.45
LoadFromFileMethod · 0.45
OnWorkStartedLockedMethod · 0.45
ReadLockedMethod · 0.45
GetNumLinesInTextFileFunction · 0.45
NextMethod · 0.45
GetNextInternalMethod · 0.45

Calls 6

clearMethod · 0.45
appendMethod · 0.45
emptyMethod · 0.45
backMethod · 0.45
resizeMethod · 0.45
sizeMethod · 0.45

Tested by 2

TESTFunction · 0.36
TESTFunction · 0.36