@@ -3140,6 +3140,7 @@ public abstract static class StringAwkSplitPrimitiveNode extends PrimitiveArrayA
3140
3140
@ Child GetByteCodeRangeNode codeRangeNode = GetByteCodeRangeNode .create ();
3141
3141
3142
3142
private static final int SUBSTRING_CREATED = -1 ;
3143
+ private static final int DEFAULT_SPLIT_VALUES_SIZE = 10 ;
3143
3144
3144
3145
@ Specialization (guards = "is7Bit(tstring, encoding, codeRangeNode)" )
3145
3146
protected Object stringAwkSplitAsciiOnly (Object string , int limit , Object block ,
@@ -3154,7 +3155,8 @@ protected Object stringAwkSplitAsciiOnly(Object string, int limit, Object block,
3154
3155
@ Cached LoopConditionProfile loopProfile ,
3155
3156
@ Bind ("strings.getTString(string)" ) AbstractTruffleString tstring ,
3156
3157
@ Bind ("strings.getEncoding(string)" ) RubyEncoding encoding ) {
3157
- Object [] ret = new Object [10 ];
3158
+ int retSize = limit > 0 && limit < DEFAULT_SPLIT_VALUES_SIZE ? limit : DEFAULT_SPLIT_VALUES_SIZE ;
3159
+ Object [] ret = new Object [retSize ];
3158
3160
int storeIndex = 0 ;
3159
3161
3160
3162
int byteLength = tstring .byteLength (encoding .tencoding );
@@ -3230,7 +3232,8 @@ protected Object stringAwkSplit(Object string, int limit, Object block,
3230
3232
@ Cached LoopConditionProfile loopProfile ,
3231
3233
@ Bind ("strings.getTString(string)" ) AbstractTruffleString tstring ,
3232
3234
@ Bind ("strings.getEncoding(string)" ) RubyEncoding encoding ) {
3233
- Object [] ret = new Object [10 ];
3235
+ int retSize = limit > 0 && limit < DEFAULT_SPLIT_VALUES_SIZE ? limit : DEFAULT_SPLIT_VALUES_SIZE ;
3236
+ Object [] ret = new Object [retSize ];
3234
3237
int storeIndex = 0 ;
3235
3238
3236
3239
final boolean limitPositive = limit > 0 ;
0 commit comments