Skip to content

Commit 9360e40

Browse files
markhbradyError Prone Team
authored andcommitted
Use VisitorState.memoize for common type suppliers, to minimize (slower) calls to getTypeFromString
PiperOrigin-RevId: 833837759
1 parent 885b213 commit 9360e40

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

check_api/src/main/java/com/google/errorprone/suppliers/Suppliers.java

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -133,29 +133,11 @@ public Type get(VisitorState state) {
133133
}
134134
};
135135

136-
public static final Supplier<Type> JAVA_LANG_BOOLEAN_TYPE =
137-
new Supplier<Type>() {
138-
@Override
139-
public Type get(VisitorState state) {
140-
return state.getTypeFromString("java.lang.Boolean");
141-
}
142-
};
136+
public static final Supplier<Type> JAVA_LANG_BOOLEAN_TYPE = typeFromString("java.lang.Boolean");
143137

144-
public static final Supplier<Type> JAVA_LANG_INTEGER_TYPE =
145-
new Supplier<Type>() {
146-
@Override
147-
public Type get(VisitorState state) {
148-
return state.getTypeFromString("java.lang.Integer");
149-
}
150-
};
138+
public static final Supplier<Type> JAVA_LANG_INTEGER_TYPE = typeFromString("java.lang.Integer");
151139

152-
public static final Supplier<Type> JAVA_LANG_LONG_TYPE =
153-
new Supplier<Type>() {
154-
@Override
155-
public Type get(VisitorState state) {
156-
return state.getTypeFromString("java.lang.Long");
157-
}
158-
};
140+
public static final Supplier<Type> JAVA_LANG_LONG_TYPE = typeFromString("java.lang.Long");
159141

160142
public static final Supplier<Type> STRING_TYPE =
161143
new Supplier<Type>() {

0 commit comments

Comments
 (0)