diff options
author | 2018-06-05 09:42:59 -0700 | |
---|---|---|
committer | 2018-06-05 09:45:02 -0700 | |
commit | fc23edc368244849c59636d1e2ae6c375bebf262 (patch) | |
tree | 2d742b93785efbd2f1fbe21de03972edd4838d7b /src/test/java/com/google/devtools/build/lib/syntax/LexerTest.java | |
parent | c04ce79e4f719df54e3564f58a2ea26529ac1494 (diff) |
Stop allocating new tokens in the lexer
There's only one Token and it gets reused.
This reduces the memory usage of the lexer. Parsing time seems to be 5%-10%
faster with this change on a large file. This makes little difference on the
overall performance of Bazel though.
RELNOTES: None.
PiperOrigin-RevId: 199310860
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/syntax/LexerTest.java')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/syntax/LexerTest.java | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/LexerTest.java b/src/test/java/com/google/devtools/build/lib/syntax/LexerTest.java index ccb968b9e4..379d955513 100644 --- a/src/test/java/com/google/devtools/build/lib/syntax/LexerTest.java +++ b/src/test/java/com/google/devtools/build/lib/syntax/LexerTest.java @@ -63,7 +63,7 @@ public class LexerTest { Token tok; do { tok = lexer.nextToken(); - result.add(tok); + result.add(tok.copy()); } while (tok.kind != TokenKind.EOF); return result; } |