mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[performance] IDEA-311162 AbstractBundle captures new empty Object arrays in getLazyMessage result
GitOrigin-RevId: d36d4c6e4bb25fbbf4f02977a792305d9cce9e2f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
00ca763837
commit
972bad4246
@@ -2,6 +2,7 @@
|
||||
package com.intellij;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.DefaultBundleService;
|
||||
import com.intellij.util.lang.UrlClassLoader;
|
||||
import org.jetbrains.annotations.*;
|
||||
@@ -76,7 +77,8 @@ public class AbstractBundle {
|
||||
}
|
||||
|
||||
public @NotNull Supplier<@Nls String> getLazyMessage(@NotNull @NonNls String key, Object @NotNull ... params) {
|
||||
return () -> getMessage(key, params);
|
||||
Object[] actualParams = params.length == 0 ? ArrayUtil.EMPTY_OBJECT_ARRAY : params; // do not capture new empty Object[] arrays here
|
||||
return () -> getMessage(key, actualParams);
|
||||
}
|
||||
|
||||
public @Nullable @Nls String messageOrNull(@NotNull @NonNls String key, Object @NotNull ... params) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.intellij.grazie
|
||||
|
||||
import com.intellij.AbstractBundle
|
||||
import com.intellij.DynamicBundle
|
||||
import com.intellij.util.ArrayUtil
|
||||
import org.jetbrains.annotations.Nls
|
||||
import org.jetbrains.annotations.PropertyKey
|
||||
import java.util.function.Supplier
|
||||
@@ -22,7 +23,8 @@ object GrazieBundle {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun messagePointer(@PropertyKey(resourceBundle = DEFAULT_BUNDLE_NAME) key: String, vararg params: Any): Supplier<String> = Supplier {
|
||||
message(key, *params)
|
||||
fun messagePointer(@PropertyKey(resourceBundle = DEFAULT_BUNDLE_NAME) key: String, vararg params: Any): Supplier<String> {
|
||||
val actualParams = if (params.isEmpty()) ArrayUtil.EMPTY_OBJECT_ARRAY else params
|
||||
return Supplier { message(key, *actualParams) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ import org.jetbrains.annotations.Nls
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import java.util.function.Consumer
|
||||
import java.util.function.Supplier
|
||||
|
||||
private val LOG = logger<SpellCheckerManager>()
|
||||
private val BUNDLED_EP_NAME = ExtensionPointName<BundledDictionaryProvider>("com.intellij.spellchecker.bundledDictionaryProvider")
|
||||
@@ -310,14 +311,13 @@ class SpellCheckerManager(val project: Project) : Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
internal enum class DictionaryLevel(private val nameSupplier: () -> String?) {
|
||||
internal enum class DictionaryLevel(private val nameSupplier: Supplier<@Nls String>) {
|
||||
APP(SpellCheckerBundle.messagePointer("dictionary.name.application.level")),
|
||||
PROJECT(SpellCheckerBundle.messagePointer("dictionary.name.project.level")),
|
||||
NOT_SPECIFIED(SpellCheckerBundle.messagePointer("dictionary.name.not.specified"));
|
||||
|
||||
@Suppress("HardCodedStringLiteral")
|
||||
@Nls
|
||||
fun getName(): String? = nameSupplier()
|
||||
fun getName(): String = nameSupplier.get()
|
||||
|
||||
companion object {
|
||||
private val DICTIONARY_LEVELS = EnumSet.allOf(DictionaryLevel::class.java).associateBy { it.getName() }
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.intellij.DynamicBundle
|
||||
import org.jetbrains.annotations.Nls
|
||||
import org.jetbrains.annotations.NonNls
|
||||
import org.jetbrains.annotations.PropertyKey
|
||||
import java.util.function.Supplier
|
||||
|
||||
private const val BUNDLE: @NonNls String = "messages.SpellCheckerBundle"
|
||||
|
||||
@@ -15,5 +16,7 @@ internal object SpellCheckerBundle : DynamicBundle(BUNDLE) {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun messagePointer(key: @PropertyKey(resourceBundle = BUNDLE) String, vararg params: Any): () -> String = { getMessage(key, *params) }
|
||||
fun messagePointer(key: @PropertyKey(resourceBundle = BUNDLE) String, vararg params: Any): Supplier<@Nls String> {
|
||||
return getLazyMessage(key, params)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user