Details
- Reviewers
amckinley - Maniphest Tasks
- T3130: Improve recognition of symbols in Java
T13195: 2018 Week 36 Bonus Content - Commits
- rPHUa28f6e5d64f3: Port the Java fragment lexer to PHP
Diff Detail
- Repository
- rPHU libphutil
- Branch
- java1
- Lint
Lint Passed - Unit
Tests Passed - Build Status
Buildable 20738 Build 28195: Run Core Tests Build 28194: arc lint + arc unit
Event Timeline
The major motivation here is to avoid the python startup overhead when highlighting small snippets. Highlighting one line of Java by calling out to pygmentize takes a minimum of ~60ms on my machine, compared to <1ms with a PHP lexer.
We're also slightly faster on very large files from what I can tell (locally, ~200ms for PHP vs ~300ms for Python for a 3K line file I pulled out of ElasticSearch, both with full startup costs) but the differences are most stark for many small files (like highlighting a lot of little snippets for rendering inline comments into mail).
Assuming most of this came from the Pygments source, can you link to that file from this revision for reference?
| src/lexer/PhutilJavaFragmentLexer.php | ||
|---|---|---|
| 41 | TIL the strictfp declaration in Java. | |
| 73–120 | I'm not even going to pretend to review the accuracy of these regexes as long as a test snippet looks reasonable. | |
