Mercurial > hg > graal-jvmci-8
diff graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/TypeSystemData.java @ 16814:e8d9b3827d4b
Truffle-DSL: added hashing for type lookups.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Wed, 13 Aug 2014 18:06:18 +0200 |
parents | 23415229349b |
children | b8470fcec3a3 |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/TypeSystemData.java Wed Aug 13 18:06:18 2014 +0200 +++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/TypeSystemData.java Wed Aug 13 18:06:18 2014 +0200 @@ -35,6 +35,7 @@ private List<TypeData> types; private List<TypeMirror> primitiveTypeMirrors = new ArrayList<>(); private List<TypeMirror> boxedTypeMirrors = new ArrayList<>(); + private Map<TypeMirror, TypeData> cachedTypes = new HashMap<>(); private List<ImplicitCastData> implicitCasts; private List<TypeCastData> casts; @@ -58,6 +59,7 @@ for (TypeData typeData : types) { primitiveTypeMirrors.add(typeData.getPrimitiveType()); boxedTypeMirrors.add(typeData.getBoxedType()); + cachedTypes.put(typeData.getPrimitiveType(), typeData); } } } @@ -152,10 +154,9 @@ } public int findType(TypeMirror type) { - for (int i = 0; i < types.size(); i++) { - if (ElementUtils.typeEquals(types.get(i).getPrimitiveType(), type)) { - return i; - } + TypeData data = cachedTypes.get(type); + if (data != null) { + return data.getIndex(); } return -1; }