Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Performance improvement in rary_concat().

  • Loading branch information...
commit db1e9fc27f6be6daa35c464cda634cc7d9ab2cd3 1 parent c1833dd
@Watson1978 Watson1978 authored
Showing with 11 additions and 4 deletions.
  1. +3 −4 array.c
  2. +8 −0 macruby_internal.h
View
7 array.c
@@ -109,10 +109,9 @@ rary_concat(VALUE ary, VALUE other, size_t beg, size_t len)
{
rary_reserve(ary, RARY(ary)->len + len);
if (IS_RARY(other)) {
- for (size_t i = 0; i < len; i++) {
- rary_elt_set(ary, i + RARY(ary)->len,
- rary_elt(other, beg + i));
- }
+ GC_MEMMOVE(&RARY(ary)->elements[RARY(ary)->beg + RARY(ary)->len],
+ &RARY(other)->elements[RARY(other)->beg + beg],
+ sizeof(VALUE) * len);
}
else {
for (size_t i = 0; i < len; i++) {
View
8 macruby_internal.h
@@ -32,6 +32,7 @@ void auto_zone_add_root(void *zone, void *address_of_root_ptr, void *value);
void auto_zone_retain(void *zone, void *ptr);
unsigned int auto_zone_release(void *zone, void *ptr);
unsigned int auto_zone_retain_count(void *zone, const void *ptr);
+void *auto_zone_write_barrier_memmove(void *zone, void *dst, const void *src, size_t size);
extern void *__auto_zone;
#else
extern auto_zone_t *__auto_zone;
@@ -72,6 +73,13 @@ rb_objc_retain_count(const void *addr)
#define GC_RETAIN_COUNT(obj) (rb_objc_retain_count((const void *)obj))
static inline void *
+rb_objc_memmove(void *dst, const void *src, size_t size)
+{
+ return auto_zone_write_barrier_memmove(__auto_zone, dst, src, size);
+}
+#define GC_MEMMOVE(dst, src, size) (rb_objc_memmove(dst, src, size))
+
+static inline void *
rb_objc_release(void *addr)
{
if (addr != NULL && !SPECIAL_CONST_P(addr)) {
Please sign in to comment.
Something went wrong with that request. Please try again.