[PATCH] D104137: Optimize lld::elf::ScriptLexer::getLineNumber by avoiding repeated work

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 13 10:48:26 PDT 2021


MaskRay added inline comments.


================
Comment at: lld/ELF/ScriptLexer.cpp:65
+
+  const size_t tokOffset = tok.data() - s.data();
+
----------------
the prevailing style is compact. You can move `tokOffset` immediately below `StringRef tok` and delete the extra empty lines 

```
  // For the first token, or when going backwards, start from the beginning of
  // the buffer. If this token is after the previous token start from the previous token.
  size_t line = 1;
  size_t start = 0;
  if (lastLineNumberOffset > 0 && tokOffset >= lastLineNumberOffset) {
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104137/new/

https://reviews.llvm.org/D104137



More information about the llvm-commits mailing list