Skip to content

Commit 0916f50

Browse files
committed
updates
1 parent b942000 commit 0916f50

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/array.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,6 @@ static jl_array_t *_new_array_(jl_value_t *atype, uint32_t ndims, size_t *dims,
7878
// extra byte for all julia allocated byte arrays
7979
tot++;
8080
}
81-
jl_value_t *el_type = (jl_value_t*)jl_tparam0(jl_typeof(atype));
82-
if (jl_is_uniontype(el_type)) {
83-
printf("here 3");
84-
// allocate an extra sel byte for each element
85-
tot += nel;
86-
}
8781
}
8882
else {
8983
wideint_t prod = (wideint_t)sizeof(void*) * (wideint_t)nel;
@@ -155,7 +149,7 @@ static inline jl_array_t *_new_array(jl_value_t *atype, uint32_t ndims, size_t *
155149
if (jl_is_uniontype(el_type)) {
156150
size_t fsz = 0, al = 0;
157151
unsigned countbits = jl_union_isbits(el_type, &fsz, &al);
158-
elsz = fsz;
152+
elsz = fsz + 1;
159153
}
160154
else {
161155
elsz = jl_datatype_size(el_type);
@@ -504,8 +498,7 @@ JL_DLLEXPORT jl_value_t *jl_arrayref(jl_array_t *a, size_t i)
504498
if (!a->flags.ptrarray) {
505499
jl_value_t *el_type = (jl_value_t*)jl_tparam0(jl_typeof(a));
506500
if (jl_is_uniontype(el_type)) {
507-
printf("here 1");
508-
uint8_t sel = ((uint8_t*)a->data)[jl_array_len(a) * a->elsize + i];
501+
uint8_t sel = ((uint8_t*)a->data)[jl_array_len(a) * (a->elsize-1) + i];
509502
el_type = jl_nth_union_component(el_type, sel);
510503
if (jl_is_datatype_singleton((jl_datatype_t*)el_type))
511504
return ((jl_datatype_t*)el_type)->instance;
@@ -570,8 +563,7 @@ JL_DLLEXPORT void jl_arrayset(jl_array_t *a, jl_value_t *rhs, size_t i)
570563
}
571564
if (!a->flags.ptrarray) {
572565
if (jl_is_uniontype(el_type)) {
573-
printf("here 2");
574-
uint8_t *psel = &((uint8_t*)a->data)[jl_array_len(a) * a->elsize + i];
566+
uint8_t *psel = &((uint8_t*)a->data)[jl_array_len(a) * (a->elsize-1) + i];
575567
unsigned nth = 0;
576568
if (!jl_find_union_component(el_type, jl_typeof(rhs), &nth))
577569
assert(0 && "invalid field assignment to isbits union");

0 commit comments

Comments
 (0)