@@ -104,35 +104,21 @@ protected DynamicDictLiteralNode(ExpressionNode[] keys, ExpressionNode[] values)
104
104
}
105
105
}
106
106
107
- static final class Keys {
108
- public final Object [] keys ;
109
- public final boolean allStrings ;
110
-
111
- Keys (Object [] keys , boolean allStrings ) {
112
- this .keys = keys ;
113
- this .allStrings = allStrings ;
114
- }
115
- }
116
-
117
107
@ ExplodeLoop
118
- private Keys evalKeys (VirtualFrame frame ) {
108
+ private HashingStorage eval (VirtualFrame frame , PythonLanguage lang , ConditionProfile hasFrame ) {
119
109
boolean allStrings = true ;
120
110
Object [] evalKeys = new Object [this .keys .length ];
111
+ Object [] evalValues = new Object [this .values .length ];
121
112
for (int i = 0 ; i < values .length ; i ++) {
122
113
evalKeys [i ] = keys [i ].execute (frame );
123
- if (!(evalKeys [i ] instanceof String )) {
114
+ evalValues [i ] = values [i ].execute (frame );
115
+ if (allStrings && !(evalKeys [i ] instanceof String )) {
124
116
allStrings = false ;
125
117
}
126
118
}
127
- return new Keys (evalKeys , allStrings );
128
- }
129
-
130
- @ ExplodeLoop
131
- private HashingStorage evalAndSetValues (VirtualFrame frame , HashingStorage dictStorage , Keys evalKeys , ConditionProfile hasFrame ) {
132
- HashingStorage storage = dictStorage ;
119
+ HashingStorage storage = PDict .createNewStorage (lang , allStrings , evalKeys .length );
133
120
for (int i = 0 ; i < values .length ; i ++) {
134
- Object val = values [i ].execute (frame );
135
- storage = libs [i ].setItemWithFrame (storage , evalKeys .keys [i ], val , hasFrame , frame );
121
+ storage = libs [i ].setItemWithFrame (storage , evalKeys [i ], evalValues [i ], hasFrame , frame );
136
122
}
137
123
return storage ;
138
124
}
@@ -141,9 +127,7 @@ private HashingStorage evalAndSetValues(VirtualFrame frame, HashingStorage dictS
141
127
public PDict create (VirtualFrame frame ,
142
128
@ CachedLanguage PythonLanguage lang ,
143
129
@ Cached ("createBinaryProfile()" ) ConditionProfile hasFrame ) {
144
- Keys evalKeys = evalKeys (frame );
145
- HashingStorage dictStorage = PDict .createNewStorage (lang , evalKeys .allStrings , evalKeys .keys .length );
146
- dictStorage = evalAndSetValues (frame , dictStorage , evalKeys , hasFrame );
130
+ HashingStorage dictStorage = eval (frame , lang , hasFrame );
147
131
return factory .createDict (dictStorage );
148
132
}
149
133
}
0 commit comments