summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--lib/pure/ropes.nim13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/pure/ropes.nim b/lib/pure/ropes.nim
index df7071642..6e97237e0 100644
--- a/lib/pure/ropes.nim
+++ b/lib/pure/ropes.nim
@@ -134,11 +134,16 @@ proc rope*(s: string): Rope {.rtl, extern: "nro$1Str".} =
   ## Converts a string to a rope.
   if s.len == 0:
     result = nil
-  elif cacheEnabled:
-    result = insertInCache(s, cache)
-    cache = result
   else:
-    result = newRope(s)
+    when nimvm:
+      # No caching in VM context
+      result = newRope(s)
+    else:
+      if cacheEnabled:
+        result = insertInCache(s, cache)
+        cache = result
+      else:
+        result = newRope(s)
 
 proc rope*(i: BiggestInt): Rope {.rtl, extern: "nro$1BiggestInt".} =
   ## Converts an int to a rope.