mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[minimap] IJPL-248674 avoid quadratic minimap color lookup
(cherry picked from commit 2872db6eece859e673c4d4dac961b0b75961d95d) IJ-CR-210985 GitOrigin-RevId: b011da98e97c12c82c2d0afc5e811dba3e878120
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b2e6948862
commit
b859639a82
+14
-5
@@ -82,13 +82,22 @@ class MinimapTokenColorContext(
|
||||
computeLineColorRuns(editorEx, lineStart, lineEnd)
|
||||
}
|
||||
|
||||
for (run in runs) {
|
||||
if (probeOffset in run.startOffset until run.endOffset) {
|
||||
return run.color
|
||||
return runForOffset(runs, probeOffset)?.color ?: defaultForeground
|
||||
}
|
||||
|
||||
private fun runForOffset(runs: List<ColorRun>, offset: Int): ColorRun? {
|
||||
var low = 0
|
||||
var high = runs.size - 1
|
||||
while (low <= high) {
|
||||
val mid = (low + high) ushr 1
|
||||
val run = runs[mid]
|
||||
when {
|
||||
offset < run.startOffset -> high = mid - 1
|
||||
offset >= run.endOffset -> low = mid + 1
|
||||
else -> return run
|
||||
}
|
||||
}
|
||||
|
||||
return defaultForeground
|
||||
return null
|
||||
}
|
||||
|
||||
private fun computeLineColorRuns(editorEx: EditorEx, lineStart: Int, lineEnd: Int): List<ColorRun> {
|
||||
|
||||
Reference in New Issue
Block a user