History

sl_cv: make inline space not an array but just a single byte

Sigrid Solveig Haflínudóttir committed 10 months ago

Commit 8ba2cfd1 parent 76ac96f2 files · +6 −6Browse files

Unified · Split

2 files
  1. src/cvalues.c +4 −4
  2. src/sl.h +2 −2
src/cvalues.c+4−4
@@ -119,7 +119,7 @@ cvalue_(const sl_type *type, usize sz, bool nofinalize) · 118 unmodified lines
119119 usize nw = CVALUE_NWORDS + NWORDS(sz);
120120 pcv = alloc_words(nw);
121121 pcv->type = type;
122− pcv->data = pcv->_space;
122+ pcv->data = &pcv->_space;
123123 if(!nofinalize && type->vtable != nil)
124124 add_finalizer(pcv);
125125 }else{
@@ -772,7 +772,7 @@ cvalue_relocate(sl_v v) · 646 unmodified lines
772772 nv = alloc_words(nw);
773773 memcpy(nv, cv, nw*sizeof(sl_v));
774774 if(isinlined(cv))
775− nv->data = nv->_space;
775+ nv->data = &nv->_space;
776776 ncv = tagptr(nv, TAG_CVALUE);
777777 const sl_type *t = cv_class(cv);
778778 if(t->vtable != nil && t->vtable->relocate != nil)
@@ -802,7 +802,7 @@ cvalue_copy(sl_v v) · 23 unmodified lines
802802 memcpy(ncv->data, cv->data, len);
803803 cv_autorelease(ncv);
804804 }else{
805− ncv->data = ncv->_space;
805+ ncv->data = &ncv->_space;
806806 }
807807
808808 return tagptr(ncv, TAG_CVALUE);
@@ -1590,5 +1590,5 @@ cvalues_init(void) · 781 unmodified lines
15901590 sl_strtype = get_type(mk_list2(sl_arrsym, sl_utf8sym), 0);
15911591 sl_emptystr = cvalue_from_ref(sl_strtype, (char*)"", 0);
15921592 sl_cv *cv = ptr(sl_cv, sl_emptystr);
1593− cv->data = cv->_space;
1593+ cv->data = &cv->_space;
15941594 }
src/sl.h+2−2
@@ -115,7 +115,7 @@ struct sl_builtin { · 114 unmodified lines
115115 #define ubnumval(v) ((sl_fx)(v)>>TAG_EXT_BITS)
116116 #define builtin(v) tagptr(((sl_v)(v)<<TAG_BITS), TAG_FN)
117117 #define bothfixnums(x, y) (isfixnum(x) && isfixnum(y))
118−#define isinlined(cv) ((cv)->data == (cv)->_space)
118+#define isinlined(cv) ((cv)->data == &(cv)->_space)
119119
120120 #define mk_rune(r) (((sl_v)(r))<<TAG_EXT_BITS | 0xfc)
121121 #define sl_isrune(v) (((v) & 0xff) == 0xfc)
@@ -314,7 +314,7 @@ struct sl_cv { · 192 unmodified lines
314314 u32int startbytes;
315315 u32int startrune;
316316 };
317− u8int _space[1]; // variable size
317+ u8int _space; // variable size
318318 };
319319 }sl_aligned(8);
320320

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t