Skip to content

Commit a66c570

Browse files
committed
avoid using both hasDict and getDict in ReadAttributeFromObjectNode
1 parent e01509b commit a66c570

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/attributes/ReadAttributeFromObjectNode.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import com.oracle.graal.python.nodes.util.CannotCastException;
6161
import com.oracle.graal.python.nodes.util.CastToJavaStringNode;
6262
import com.oracle.graal.python.runtime.PythonOptions;
63+
import com.oracle.truffle.api.dsl.Bind;
6364
import com.oracle.truffle.api.dsl.Cached;
6465
import com.oracle.truffle.api.dsl.GenerateUncached;
6566
import com.oracle.truffle.api.dsl.ImportStatic;
@@ -143,12 +144,13 @@ protected static Object readFromBuiltinModuleDict(PythonModule object, String ke
143144
// read from the Dict
144145
@Specialization(guards = {
145146
"!isHiddenKey(key)",
146-
"lib.hasDict(object)"
147+
"dict != null"
147148
}, replaces = "readFromBuiltinModuleDict")
148149
protected static Object readFromDict(PythonObject object, Object key,
149150
@CachedLibrary(limit = "MAX_DICT_TYPES") PythonObjectLibrary lib,
151+
@Bind("lib.getDict(object)") PDict dict,
150152
@CachedLibrary(limit = "MAX_DICT_TYPES") HashingStorageLibrary hlib) {
151-
Object value = hlib.getItem(lib.getDict(object).getDictStorage(), key);
153+
Object value = hlib.getItem(dict.getDictStorage(), key);
152154
if (value == null) {
153155
return PNone.NO_VALUE;
154156
} else {

0 commit comments

Comments
 (0)