diff --git a/src/julia.h b/src/julia.h index 26a6117822bb3..8b2b9480abe2b 100644 --- a/src/julia.h +++ b/src/julia.h @@ -914,7 +914,7 @@ STATIC_INLINE jl_value_t *jl_svecset( // TODO: while svec is supposedly immutable, in practice we sometimes publish it first // and set the values lazily. Those users should be using jl_atomic_store_release here. jl_svec_data(t)[i] = (jl_value_t*)x; - if (x) jl_gc_wb(t, x); + jl_gc_wb(t, x); return (jl_value_t*)x; } #endif diff --git a/src/simplevector.c b/src/simplevector.c index fa21330b23ab4..988cf18ccc9b6 100644 --- a/src/simplevector.c +++ b/src/simplevector.c @@ -13,7 +13,7 @@ JL_DLLEXPORT jl_svec_t *(ijl_svec)(size_t n, ...) if (n == 0) return jl_emptysvec; va_start(args, n); jl_svec_t *jv = jl_alloc_svec_uninit(n); - for(size_t i=0; i < n; i++) + for (size_t i = 0; i < n; i++) jl_svecset(jv, i, va_arg(args, jl_value_t*)); va_end(args); return jv; @@ -38,7 +38,7 @@ JL_DLLEXPORT jl_svec_t *jl_svec1(void *a) jl_svec_t *v = (jl_svec_t*)jl_gc_alloc(ct->ptls, sizeof(void*) * 2, jl_simplevector_type); jl_svec_set_len_unsafe(v, 1); - jl_svecset(v, 0, a); + jl_svec_data(v)[0] = (jl_value_t*)a; return v; } @@ -48,8 +48,8 @@ JL_DLLEXPORT jl_svec_t *jl_svec2(void *a, void *b) jl_svec_t *v = (jl_svec_t*)jl_gc_alloc(ct->ptls, sizeof(void*) * 3, jl_simplevector_type); jl_svec_set_len_unsafe(v, 2); - jl_svecset(v, 0, a); - jl_svecset(v, 1, b); + jl_svec_data(v)[0] = (jl_value_t*)a; + jl_svec_data(v)[1] = (jl_value_t*)b; return v; } @@ -67,26 +67,24 @@ JL_DLLEXPORT jl_svec_t *jl_alloc_svec(size_t n) { if (n == 0) return jl_emptysvec; jl_svec_t *jv = jl_alloc_svec_uninit(n); - for(size_t i=0; i < n; i++) - jl_svecset(jv, i, NULL); + memset(jl_assume_aligned(jl_svec_data(jv), sizeof(void*)), 0, n * sizeof(void*)); return jv; } JL_DLLEXPORT jl_svec_t *jl_svec_copy(jl_svec_t *a) { - size_t i, n=jl_svec_len(a); + size_t n = jl_svec_len(a); jl_svec_t *c = jl_alloc_svec_uninit(n); - for(i=0; i < n; i++) - jl_svecset(c, i, jl_svecref(a,i)); + memmove_refs((void**)jl_svec_data(c), (void**)jl_svec_data(a), n); return c; } JL_DLLEXPORT jl_svec_t *jl_svec_fill(size_t n, jl_value_t *x) { - if (n==0) return jl_emptysvec; + if (n == 0) return jl_emptysvec; jl_svec_t *v = jl_alloc_svec_uninit(n); - for(size_t i=0; i < n; i++) - jl_svecset(v, i, x); + for (size_t i = 0; i < n; i++) + jl_svec_data(v)[i] = x; return v; }