Skip to content

Commit

Permalink
Avoid repeated hash lookups in getGreatestSubtypeWithProperty
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=139823455
  • Loading branch information
concavelenz authored and blickly committed Nov 22, 2016
1 parent b5620d3 commit 9ec354d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/com/google/javascript/rhino/jstype/JSTypeRegistry.java
Expand Up @@ -772,12 +772,13 @@ public void unregisterPropertyOnType(String propertyName, JSType type) {
*/
public JSType getGreatestSubtypeWithProperty(
JSType type, String propertyName) {
if (greatestSubtypeByProperty.containsKey(propertyName)) {
return greatestSubtypeByProperty.get(propertyName)
.getGreatestSubtype(type);
JSType withProperty = greatestSubtypeByProperty.get(propertyName);
if (withProperty != null) {
return withProperty.getGreatestSubtype(type);
}
if (typesIndexedByProperty.containsKey(propertyName)) {
JSType built = typesIndexedByProperty.get(propertyName).build();
UnionTypeBuilder typesWithProp = typesIndexedByProperty.get(propertyName);
if (typesWithProp != null) {
JSType built = typesWithProp.build();
greatestSubtypeByProperty.put(propertyName, built);
return built.getGreatestSubtype(type);
}
Expand Down

0 comments on commit 9ec354d

Please sign in to comment.