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
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
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 | ||
---|---|---|
42 | TIL the strictfp declaration in Java. | |
74–121 | I'm not even going to pretend to review the accuracy of these regexes as long as a test snippet looks reasonable. |