Skip to content

Commit 2a9bed5

Browse files
original-brownbearcbuescher
authored andcommitted
Speedup string interning in ClusterName (elastic#112045)
If we want to intern here, we should use the deduplicator to speed things up.
1 parent 7f63891 commit 2a9bed5

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

server/src/main/java/org/elasticsearch/cluster/ClusterName.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ public ClusterName(StreamInput input) throws IOException {
3939
}
4040

4141
public ClusterName(String value) {
42-
this.value = value.intern();
42+
// cluster name string is most likely part of a setting so we can speed things up over outright interning here
43+
this.value = Settings.internKeyOrValue(value);
4344
}
4445

4546
public String value() {

server/src/main/java/org/elasticsearch/common/settings/Settings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,7 @@ private static String toString(Object o) {
15671567
* @param s string to intern
15681568
* @return interned string
15691569
*/
1570-
static String internKeyOrValue(String s) {
1570+
public static String internKeyOrValue(String s) {
15711571
return settingLiteralDeduplicator.deduplicate(s);
15721572
}
15731573

0 commit comments

Comments
 (0)