summaryrefslogtreecommitdiff
path: root/darray.h
diff options
context:
space:
mode:
authorMaxime Chevalier-Boisvert <maximechevalierb@gmail.com>2021-04-19 17:07:27 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2021-10-20 18:19:33 -0400
commit0cc73ca2a9a2aa5276cd022be9891475a15ecee3 (patch)
tree7089bb4d352277b6129c7e3af7444ff09f548c0a /darray.h
parent33c975b813a2be9fb02e526b7a63096dff385614 (diff)
downloadruby-0cc73ca2a9a2aa5276cd022be9891475a15ecee3.tar.gz
Malloc branch entries (#112)
* Malloc branch entries * Add ASM comment for stack overflow check * WIP * Fix branch GC code. Add rb_darray_remove_unordered(). * Fix block end_pos after branch rewriting. Remove dst_patched bits.
Diffstat (limited to 'darray.h')
-rw-r--r--darray.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/darray.h b/darray.h
index 71e2d7e6ce..b613d08489 100644
--- a/darray.h
+++ b/darray.h
@@ -51,10 +51,20 @@
1 \
) : 0)
+// Last element of the array
+//
+#define rb_darray_back(ary) ((ary)->data[(ary)->meta.size - 1])
+
// Remove the last element of the array.
//
#define rb_darray_pop_back(ary) ((ary)->meta.size--)
+// Remove element at idx and replace it by the last element
+#define rb_darray_remove_unordered(ary, idx) do { \
+ rb_darray_set(ary, idx, rb_darray_back(ary)); \
+ rb_darray_pop_back(ary); \
+} while (0);
+
// Iterate over items of the array in a for loop
//
#define rb_darray_foreach(ary, idx_name, elem_ptr_var) \