Merge pull request #2532 from WalterCouto/test2
don't unnecessary fetch all tokens when grabbing an interval of text …
This commit is contained in:
commit
8be60804ab
|
@ -358,17 +358,18 @@ std::string BufferedTokenStream::getSourceName() const
|
|||
}
|
||||
|
||||
std::string BufferedTokenStream::getText() {
|
||||
fill();
|
||||
return getText(misc::Interval(0U, size() - 1));
|
||||
}
|
||||
|
||||
std::string BufferedTokenStream::getText(const misc::Interval &interval) {
|
||||
lazyInit();
|
||||
fill();
|
||||
size_t start = interval.a;
|
||||
size_t stop = interval.b;
|
||||
if (start == INVALID_INDEX || stop == INVALID_INDEX) {
|
||||
return "";
|
||||
}
|
||||
sync(stop);
|
||||
if (stop >= _tokens.size()) {
|
||||
stop = _tokens.size() - 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue