Parser.st
changeset 3997 d5d5998b6f0a
parent 3995 1701f9550f31
child 3998 0d185abc2cf0
child 4011 0d24f003c0e9
--- a/Parser.st	Fri Sep 30 17:10:59 2016 +0200
+++ b/Parser.st	Sat Oct 01 17:48:52 2016 +0200
@@ -6484,7 +6484,14 @@
 "/            self emptyStatement.
 "/        ].
     ].
-    arr := Array withAll:elements.
+
+    elements size == 0 ifTrue:[
+        "always return the same object for an empty array,
+         which is also immutable by definition"
+        ^ #().
+    ].
+
+    arr := elements asArray.
 
     parserFlags arraysAreImmutable ifTrue:[
         ^ self makeImmutableArray:arr
@@ -6791,8 +6798,8 @@
     |bytes index limit newArray elem pos1 pos2|
 
     pos1 := tokenPosition.
-    bytes := ByteArray uninitializedNew:5000.
     index := 0. limit := 5000.
+    bytes := ByteArray uninitializedNew:limit.
     [tokenType ~~ $] ] whileTrue:[
         pos2 := tokenPosition.
         "
@@ -6830,6 +6837,13 @@
         ].
         self nextToken.
     ].
+
+    index == 0 ifTrue:[
+        "always return the same object for an empty byte array,
+         which is also immutable by definition"
+        ^ #[].
+    ].
+
     newArray := ByteArray uninitializedNew:index.
     newArray replaceFrom:1 to:index with:bytes startingAt:1.
     parserFlags arraysAreImmutable ifTrue:[