summary refs log tree commit diff stats
path: root/lib/pure
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2014-12-18 14:54:26 +0100
committerAraq <rumpf_a@web.de>2014-12-18 14:54:26 +0100
commit280fa9624c0657032c671fec3ea7d9577ebf0642 (patch)
treefe51267f3f4fbdbfd45ab41df07230dc772d1e5e /lib/pure
parentfaf8d07056c4c922bc44f2f970078307c5c04c05 (diff)
downloadNim-280fa9624c0657032c671fec3ea7d9577ebf0642.tar.gz
fixes #1496
Diffstat (limited to 'lib/pure')
-rw-r--r--lib/pure/collections/queues.nim2
-rw-r--r--lib/pure/collections/rtarrays.nim37
-rw-r--r--lib/pure/pegs.nim2
3 files changed, 40 insertions, 1 deletions
diff --git a/lib/pure/collections/queues.nim b/lib/pure/collections/queues.nim
index 38e0b4212..1c0e63ddf 100644
--- a/lib/pure/collections/queues.nim
+++ b/lib/pure/collections/queues.nim
@@ -8,6 +8,8 @@
 #
 
 ## Implementation of a queue. The underlying implementation uses a ``seq``.
+## Note: For inter thread communication use
+## a `TChannel <channels.html>``_ instead.
 
 import math
 
diff --git a/lib/pure/collections/rtarrays.nim b/lib/pure/collections/rtarrays.nim
new file mode 100644
index 000000000..7782b032c
--- /dev/null
+++ b/lib/pure/collections/rtarrays.nim
@@ -0,0 +1,37 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2014 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+
+## Module that implements a fixed length array whose size
+## is determined at runtime. Note: This is not ready for other people to use!
+
+const
+  ArrayPartSize = 10
+
+type
+  RtArray*[T] = object  ##
+    L: Natural
+    spart: seq[T]
+    apart: array [ArrayPartSize, T]
+  UncheckedArray* {.unchecked.}[T] = array[0..100_000_000, T]
+
+
+template usesSeqPart(x): expr = x.L > ArrayPartSize
+
+proc initRtArray*[T](len: Natural): RtArray[T] =
+  result.L = len
+  if usesSeqPart(result):
+    newSeq(result.spart, len)
+
+proc getRawData*[T](x: var RtArray[T]): ptr UncheckedArray[T] =
+  if usesSeqPart(x): cast[ptr UncheckedArray[T]](addr(x.spart[0]))
+  else: cast[ptr UncheckedArray[T]](addr(x.apart[0]))
+
+#proc len*[T](x: RtArray[T]): int = x.L
+
diff --git a/lib/pure/pegs.nim b/lib/pure/pegs.nim
index 6eb7dee78..8b7554661 100644
--- a/lib/pure/pegs.nim
+++ b/lib/pure/pegs.nim
@@ -28,7 +28,7 @@ when useUnicode:
 
 const
   InlineThreshold = 5  ## number of leaves; -1 to disable inlining
-  MaxSubpatterns* = 10 ## defines the maximum number of subpatterns that
+  MaxSubpatterns* = 20 ## defines the maximum number of subpatterns that
                        ## can be captured. More subpatterns cannot be captured! 
 
 type