jv_free(a);
return jv_array();
}
- // FIXME FIXME FIXME large offsets
- a.offset += start;
- a.size = end - start;
- return a;
+
+ if (a.offset + start > 1 << (sizeof(a.offset) * CHAR_BIT)) {
+ jv r = jv_array_sized(end - start);
+ for (int i = start; i < end; i++)
+ r = jv_array_append(r, jv_array_get(jv_copy(a), i));
+ jv_free(a);
+ return r;
+ } else {
+ a.offset += start;
+ a.size = end - start;
+ return a;
+ }
}
/*
[0,1,"a","b",4,5,6,7]
[0,1,"a","b","c",4,5,6,7]
+# Slices at large offsets (issue #1108)
+#
+# This is written this way because [range(<large number>)] is
+# significantly slower under valgrind than .[<large number>] = value.
+#
+# We range down rather than up so that we have just one realloc.
+reduce range(70010;69999;-1) as $i ([]; .[$i] = $i)|.[69999:70003]
+null
+[null,70000,70001,70002]
#
# Variables