Skip to content

Commit fe1cf4f

Browse files
authored
make it cheaper when there is no path in ContentPath (elastic#135645)
It makes a bit cheaper to call ContentPath#pathAsText when there is actually no path as we are not copying the string ]into the string buffer.
1 parent 7bf5c48 commit fe1cf4f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

server/src/main/java/org/elasticsearch/index/mapper/ContentPath.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ public boolean isWithinLeafObject() {
5858
}
5959

6060
public String pathAsText(String name) {
61+
if (index == 0) {
62+
return name;
63+
}
6164
sb.setLength(0);
6265
for (int i = 0; i < index; i++) {
6366
sb.append(path[i]).append(DELIMITER);

0 commit comments

Comments
 (0)