@@ -181,8 +181,10 @@ public abstract static class EqNode extends PythonBinaryBuiltinNode {
181
181
@ Child private SequenceStorageNodes .CmpNode eqNode ;
182
182
183
183
@ Specialization
184
- boolean eq (VirtualFrame frame , PIBytesLike self , PIBytesLike other ) {
185
- return getEqNode ().execute (frame , self .getSequenceStorage (), other .getSequenceStorage ());
184
+ boolean eq (VirtualFrame frame , PIBytesLike self , PIBytesLike other ,
185
+ @ Cached GetSequenceStorageNode getSelfStorage ,
186
+ @ Cached GetSequenceStorageNode getOtherStorage ) {
187
+ return getEqNode ().execute (frame , getSelfStorage .execute (self ), getOtherStorage .execute (other ));
186
188
}
187
189
188
190
@ SuppressWarnings ("unused" )
@@ -209,8 +211,10 @@ public abstract static class NeNode extends PythonBinaryBuiltinNode {
209
211
@ Child SequenceStorageNodes .CmpNode eqNode ;
210
212
211
213
@ Specialization
212
- boolean ne (VirtualFrame frame , PIBytesLike self , PIBytesLike other ) {
213
- return !getEqNode ().execute (frame , self .getSequenceStorage (), other .getSequenceStorage ());
214
+ boolean ne (VirtualFrame frame , PIBytesLike self , PIBytesLike other ,
215
+ @ Cached GetSequenceStorageNode getSelfStorage ,
216
+ @ Cached GetSequenceStorageNode getOtherStorage ) {
217
+ return !getEqNode ().execute (frame , getSelfStorage .execute (self ), getOtherStorage .execute (other ));
214
218
}
215
219
216
220
@ SuppressWarnings ("unused" )
@@ -343,8 +347,9 @@ public boolean doByte(PBytes byteArray) {
343
347
344
348
@ Specialization
345
349
boolean doLen (PIBytesLike operand ,
346
- @ Cached ("create()" ) SequenceStorageNodes .LenNode lenNode ) {
347
- return lenNode .execute (operand .getSequenceStorage ()) != 0 ;
350
+ @ Cached ("create()" ) SequenceStorageNodes .LenNode lenNode ,
351
+ @ Cached GetSequenceStorageNode getSelfStorage ) {
352
+ return lenNode .execute (getSelfStorage .execute (operand )) != 0 ;
348
353
}
349
354
350
355
@ Fallback
@@ -583,8 +588,9 @@ public Object doGeneric(Object self, Object arg) {
583
588
public abstract static class LenNode extends PythonUnaryBuiltinNode {
584
589
@ Specialization
585
590
public int len (PIBytesLike self ,
586
- @ Cached ("create()" ) SequenceStorageNodes .LenNode lenNode ) {
587
- return lenNode .execute (self .getSequenceStorage ());
591
+ @ Cached ("create()" ) SequenceStorageNodes .LenNode lenNode ,
592
+ @ Cached GetSequenceStorageNode getSelfStorage ) {
593
+ return lenNode .execute (getSelfStorage .execute (self ));
588
594
}
589
595
}
590
596
@@ -603,20 +609,23 @@ private int getLength(SequenceStorage s) {
603
609
604
610
@ Specialization
605
611
boolean contains (VirtualFrame frame , PIBytesLike self , PIBytesLike other ,
606
- @ Cached ("create()" ) BytesNodes .FindNode findNode ) {
607
- return findNode .execute (frame , self , other , 0 , getLength (self .getSequenceStorage ())) != -1 ;
612
+ @ Cached ("create()" ) BytesNodes .FindNode findNode ,
613
+ @ Shared ("getSelfStorage" ) @ Cached GetSequenceStorageNode getSelfStorage ) {
614
+ return findNode .execute (frame , self , other , 0 , getLength (getSelfStorage .execute (self ))) != -1 ;
608
615
}
609
616
610
617
@ Specialization
611
618
boolean contains (VirtualFrame frame , PIBytesLike self , int other ,
612
- @ Cached ("create()" ) BytesNodes .FindNode findNode ) {
613
- return findNode .execute (frame , self , other , 0 , getLength (self .getSequenceStorage ())) != -1 ;
619
+ @ Cached ("create()" ) BytesNodes .FindNode findNode ,
620
+ @ Shared ("getSelfStorage" ) @ Cached GetSequenceStorageNode getSelfStorage ) {
621
+ return findNode .execute (frame , self , other , 0 , getLength (getSelfStorage .execute (self ))) != -1 ;
614
622
}
615
623
616
624
@ Specialization
617
625
boolean contains (VirtualFrame frame , PIBytesLike self , long other ,
618
- @ Cached ("create()" ) BytesNodes .FindNode findNode ) {
619
- return findNode .execute (frame , self , other , 0 , getLength (self .getSequenceStorage ())) != -1 ;
626
+ @ Cached ("create()" ) BytesNodes .FindNode findNode ,
627
+ @ Shared ("getSelfStorage" ) @ Cached GetSequenceStorageNode getSelfStorage ) {
628
+ return findNode .execute (frame , self , other , 0 , getLength (getSelfStorage .execute (self ))) != -1 ;
620
629
}
621
630
622
631
@ Specialization (guards = {"!isBytes(other)" })
@@ -936,22 +945,25 @@ abstract static class FindNode extends PythonBuiltinNode {
936
945
@ Specialization
937
946
int find (VirtualFrame frame , PIBytesLike self , Object sub , @ SuppressWarnings ("unused" ) PNone start , @ SuppressWarnings ("unused" ) PNone end ,
938
947
@ Shared ("lenNode" ) @ Cached SequenceStorageNodes .LenNode lenNode ,
939
- @ Shared ("findNode" ) @ Cached BytesNodes .FindNode findNode ) {
940
- return find (frame , self , sub , 0 , lenNode .execute (self .getSequenceStorage ()), findNode );
948
+ @ Shared ("findNode" ) @ Cached BytesNodes .FindNode findNode ,
949
+ @ Cached GetSequenceStorageNode getSelfStorage ) {
950
+ return find (frame , self , sub , 0 , lenNode .execute (getSelfStorage .execute (self )), findNode );
941
951
}
942
952
943
953
@ Specialization
944
954
int find (VirtualFrame frame , PIBytesLike self , Object sub , int start , @ SuppressWarnings ("unused" ) PNone end ,
945
955
@ Shared ("lenNode" ) @ Cached SequenceStorageNodes .LenNode lenNode ,
946
- @ Shared ("findNode" ) @ Cached BytesNodes .FindNode findNode ) {
947
- return find (frame , self , sub , start , lenNode .execute (self .getSequenceStorage ()), findNode );
956
+ @ Shared ("findNode" ) @ Cached BytesNodes .FindNode findNode ,
957
+ @ Cached GetSequenceStorageNode getSelfStorage ) {
958
+ return find (frame , self , sub , start , lenNode .execute (getSelfStorage .execute (self )), findNode );
948
959
}
949
960
950
961
@ Specialization
951
962
int find (VirtualFrame frame , PIBytesLike self , Object sub , Object start , @ SuppressWarnings ("unused" ) PNone end ,
952
963
@ Shared ("lenNode" ) @ Cached SequenceStorageNodes .LenNode lenNode ,
953
- @ Shared ("findNode" ) @ Cached BytesNodes .FindNode findNode ) {
954
- return find (frame , self , sub , start , lenNode .execute (self .getSequenceStorage ()), findNode );
964
+ @ Shared ("findNode" ) @ Cached BytesNodes .FindNode findNode ,
965
+ @ Cached GetSequenceStorageNode getSelfStorage ) {
966
+ return find (frame , self , sub , start , lenNode .execute (getSelfStorage .execute (self )), findNode );
955
967
}
956
968
957
969
@ Specialization
0 commit comments