Remove use of String.intern().
Me, on the blackboard: "I will not optimize code without using a profiler." "I will not optimize code without using a profiler." "I will not optimize code without using a profiler." "I will not optimize code without using a profiler." "I will not optimize code without using a profiler." ...
This commit is contained in:
@@ -839,7 +839,7 @@ public class Mustache {
|
|||||||
/** A helper class for named segments. */
|
/** A helper class for named segments. */
|
||||||
protected static abstract class NamedSegment extends Template.Segment {
|
protected static abstract class NamedSegment extends Template.Segment {
|
||||||
protected NamedSegment (String name, int line) {
|
protected NamedSegment (String name, int line) {
|
||||||
_name = name.intern();
|
_name = name;
|
||||||
_line = line;
|
_line = line;
|
||||||
}
|
}
|
||||||
protected final String _name;
|
protected final String _name;
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ public class Template {
|
|||||||
* context.
|
* context.
|
||||||
*
|
*
|
||||||
* @param ctx the context in which to look up the variable.
|
* @param ctx the context in which to look up the variable.
|
||||||
* @param name the name of the variable to be resolved, which must be an interned string.
|
* @param name the name of the variable to be resolved.
|
||||||
* @param missingIsNull whether to fail if a variable cannot be resolved, or to return null in
|
* @param missingIsNull whether to fail if a variable cannot be resolved, or to return null in
|
||||||
* that case.
|
* that case.
|
||||||
*
|
*
|
||||||
@@ -216,11 +216,11 @@ public class Template {
|
|||||||
*/
|
*/
|
||||||
protected Object getValue (Context ctx, String name, int line, boolean missingIsNull) {
|
protected Object getValue (Context ctx, String name, int line, boolean missingIsNull) {
|
||||||
// handle our special variables
|
// handle our special variables
|
||||||
if (name == FIRST_NAME) {
|
if (name.equals(FIRST_NAME)) {
|
||||||
return ctx.onFirst;
|
return ctx.onFirst;
|
||||||
} else if (name == LAST_NAME) {
|
} else if (name.equals(LAST_NAME)) {
|
||||||
return ctx.onLast;
|
return ctx.onLast;
|
||||||
} else if (name == INDEX_NAME) {
|
} else if (name.equals(INDEX_NAME)) {
|
||||||
return ctx.index;
|
return ctx.index;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,7 +257,7 @@ public class Template {
|
|||||||
// we want to allow the first component of a compound key to be located in a parent
|
// we want to allow the first component of a compound key to be located in a parent
|
||||||
// context, but once we're selecting sub-components, they must only be resolved in the
|
// context, but once we're selecting sub-components, they must only be resolved in the
|
||||||
// object that represents that component
|
// object that represents that component
|
||||||
Object data = getValue(ctx, comps[0].intern(), line, missingIsNull);
|
Object data = getValue(ctx, comps[0], line, missingIsNull);
|
||||||
for (int ii = 1; ii < comps.length; ii++) {
|
for (int ii = 1; ii < comps.length; ii++) {
|
||||||
if (data == NO_FETCHER_FOUND) {
|
if (data == NO_FETCHER_FOUND) {
|
||||||
if (!missingIsNull) throw new MustacheException.Context(
|
if (!missingIsNull) throw new MustacheException.Context(
|
||||||
@@ -269,7 +269,7 @@ public class Template {
|
|||||||
}
|
}
|
||||||
// once we step into a composite key, we drop the ability to query our parent contexts;
|
// once we step into a composite key, we drop the ability to query our parent contexts;
|
||||||
// that would be weird and confusing
|
// that would be weird and confusing
|
||||||
data = getValueIn(data, comps[ii].intern(), line);
|
data = getValueIn(data, comps[ii], line);
|
||||||
}
|
}
|
||||||
return checkForMissing(name, line, missingIsNull, data);
|
return checkForMissing(name, line, missingIsNull, data);
|
||||||
}
|
}
|
||||||
@@ -404,7 +404,7 @@ public class Template {
|
|||||||
|
|
||||||
@Override public boolean equals (Object other) {
|
@Override public boolean equals (Object other) {
|
||||||
Key okey = (Key)other;
|
Key okey = (Key)other;
|
||||||
return okey.cclass == cclass && okey.name == name;
|
return okey.cclass == cclass && okey.name.equals(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String toString () {
|
@Override public String toString () {
|
||||||
@@ -412,11 +412,11 @@ public class Template {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static final String DOT_NAME = ".".intern();
|
protected static final String DOT_NAME = ".";
|
||||||
protected static final String THIS_NAME = "this".intern();
|
protected static final String THIS_NAME = "this";
|
||||||
protected static final String FIRST_NAME = "-first".intern();
|
protected static final String FIRST_NAME = "-first";
|
||||||
protected static final String LAST_NAME = "-last".intern();
|
protected static final String LAST_NAME = "-last";
|
||||||
protected static final String INDEX_NAME = "-index".intern();
|
protected static final String INDEX_NAME = "-index";
|
||||||
|
|
||||||
/** A fetcher cached for lookups that failed to find a fetcher. */
|
/** A fetcher cached for lookups that failed to find a fetcher. */
|
||||||
protected static Mustache.VariableFetcher NOT_FOUND_FETCHER = new Mustache.VariableFetcher() {
|
protected static Mustache.VariableFetcher NOT_FOUND_FETCHER = new Mustache.VariableFetcher() {
|
||||||
|
|||||||
Reference in New Issue
Block a user