1
0
mirror of https://github.com/chylex/IntelliJ-AceJump.git synced 2025-03-10 19:32:21 +01:00

Decide whether to use parallel search based on search boundary size

This commit is contained in:
chylex 2020-11-23 02:40:45 +01:00
parent 000a57824a
commit 3c899bf595
2 changed files with 4 additions and 6 deletions
src/main/kotlin/org/acejump

View File

@ -1,9 +1,7 @@
package org.acejump.search
import com.intellij.openapi.diagnostic.Logger
import org.acejump.view.Boundary.FULL_FILE_BOUNDARY
import org.acejump.view.Model.LONG_DOCUMENT
import org.acejump.view.Model.boundaries
import org.acejump.view.Model.LONG_DOCUMENT_LENGTH
import org.acejump.view.Model.editorText
import java.util.*
import kotlin.streams.toList
@ -23,7 +21,7 @@ internal object Scanner {
*/
fun find(model: AceFindModel, boundaries: IntRange, cache: Set<Int> = emptySet()): SortedSet<Int> =
if (!LONG_DOCUMENT || cache.size != 0 || boundaries != FULL_FILE_BOUNDARY.intRange())
if (cache.isNotEmpty() || (boundaries.last - boundaries.first) < LONG_DOCUMENT_LENGTH)
editorText.search(model, cache, boundaries).toSortedSet()
else editorText.chunk().parallelStream().map { chunk ->
editorText.search(model, cache, chunk)

View File

@ -56,9 +56,9 @@ object Model {
get() = lineHeight - (editor as EditorImpl).descent - fontHeight
val arcD = rectHeight - 6
var viewBounds = 0..0
const val DEFAULT_BUFFER = 30000
const val LONG_DOCUMENT_LENGTH = 100000
val LONG_DOCUMENT
get() = DEFAULT_BUFFER < editorText.length
get() = LONG_DOCUMENT_LENGTH < editorText.length
const val MAX_TAG_RESULTS = 300
val defaultBoundary = FULL_FILE_BOUNDARY