Prism slows down web browser when showing a large XML file#313
Prism slows down web browser when showing a large XML file#313uhafner merged 3 commits intojenkinsci:mainfrom
Conversation
☀️ Quality MonitorTests Coverage for New Code 〰️ Line Coverage: 100.00% — perfect 🎉 Coverage for Whole Project 〰️ Line Coverage: 79.63% — 89 missed lines Style Bugs Vulnerabilities🛡️ OWASP Dependency Check: 217 vulnerabilities — error: 17, high: 63, normal: 126, low: 11 Software Metrics 🌀 Cyclomatic Complexity: 165 (total) 🚦 Quality GatesOverall Status: ✅ SUCCESS✅ Passed Gates
Created by Quality Monitor v4.11.0 (#484bbba). More details are shown in the GitHub Checks Result. |
uhafner
left a comment
There was a problem hiding this comment.
Looks good, thanks! Can you simplify the code?
| private static final int MAX_LINES_FOR_SYNTAX_HIGHLIGHTING = Integer.getInteger( | ||
| SourcePrinter.class.getName() + ".maxLinesForSyntaxHighlighting", 5_000); |
There was a problem hiding this comment.
Simply use 5_000, it does not make sense to use properties in Jenkins. When required we can add a customization later...
There was a problem hiding this comment.
Can you use the constant here as well?
| private int countLines(final StringBuilder text) { | ||
| if (text.isEmpty()) { | ||
| return 0; | ||
| } | ||
|
|
||
| int lines = 0; | ||
| for (int i = 0; i < text.length(); i++) { | ||
| if (text.charAt(i) == NEW_LINE) { | ||
| lines++; | ||
| } | ||
| } | ||
| return lines; | ||
| } |
There was a problem hiding this comment.
Replace with sb.chars().filter(c -> c == '\n').count()
…e line counting method
|
Thanks! |
Prism slows down web browser when showing a large XML file
Fixes #287
Testing done
Submitter checklist