History

bikeshedding

Sigrid Solveig Haflínudóttir committed 4 months ago

Commit 4b6c9041 parent a43ed212 files · +19 −19Browse files

Unified · Split

2 files
  1. src/ios.c +3 −3
  2. src/sl.c +16 −16
src/ios.c+3−3
@@ -770,12 +770,12 @@ ios_peek(ios *s, void *dest, usize n) · 769 unmodified lines
770770 int
771771 ios_peekc(ios *s)
772772 {
773− if(s->bpos < s->size)
773+ if(sl_likely(s->bpos < s->size))
774774 return (u8int)s->buf[s->bpos];
775− if(s->eof)
775+ if(sl_unlikely(s->eof))
776776 return IOS_EOF;
777777 usize n = ios_readprep(s, 1);
778− if(n == 0)
778+ if(sl_unlikely(n == 0))
779779 return IOS_EOF;
780780 return (u8int)s->buf[s->bpos];
781781 }
src/sl.c+16−16
@@ -91,7 +91,7 @@ sl_exit(const char *status) · 90 unmodified lines
9191 _ctx.osp = sl.sp - sl.stack; _ctx.frame = sl.curr_frame; \
9292 _ctx.rdst = sl.readstate; _ctx.prev = sl.exctx; \
9393 _ctx.ngchnd = slvm.ngchandles; sl.exctx = &_ctx; \
94− if(!sl_setjmp(_ctx.buf)) \
94+ if(sl_likely(!sl_setjmp(_ctx.buf))) \
9595 for(l__tr = 1; l__tr; l__tr = 0, (void)(sl.exctx = sl.exctx->prev))
9696
9797 #define SL_CATCH_INC \
@@ -1004,7 +1004,7 @@ BUILTIN("fn", fn) · 906 unmodified lines
10041004 }else if(!valsset && isvec(v)){
10051005 valsset = true;
10061006 fn->vals = v;
1007− }else if(v == sl_t){
1007+ }else if(sl_unlikely(v == sl_t)){
10081008 raw = true;
10091009 }else if(!nameset && issym(v)){
10101010 if(sl_unlikely(isgensym(v)))
@@ -1031,7 +1031,7 @@ BUILTIN("fn", fn) · 20 unmodified lines
10311031 bthrow(error(sl_errarg, "no code"));
10321032 if(sl_unlikely(!maxstackset))
10331033 bthrow(error(sl_errarg, "no max stack"));
1034− if(!raw){
1034+ if(sl_likely(!raw)){
10351035 // read syntax, shifted 48 for compact text representation
10361036 for(usize j = 0; j < sz; j++)
10371037 data[j] -= 48;
@@ -1280,7 +1280,8 @@ map_seq(sl_v rt, sl_v *args, int nargs) · 242 unmodified lines
12801280 bthrow(type_error(nil, "sequence", v));
12811281 POPN(pargs+1);
12821282 switch(rtype){
1283− default:
1283+ case RT_NIL:
1284+ sl.stack[k+1] = sl_nil;
12841285 break;
12851286 case RT_VEC:
12861287 sl.stack[k+1] = alloc_vec(n, 0);
@@ -1303,8 +1304,7 @@ map_seq(sl_v rt, sl_v *args, int nargs) · 16 unmodified lines
13031304 sl.stack[k+1] = applyn(2*n);
13041305 POPN(2*n);
13051306 break;
1306− case RT_NIL:
1307− sl.stack[k+1] = sl_nil;
1307+ default:
13081308 break;
13091309 }
13101310 sl_v res = sl.stack[k+1];
@@ -1314,15 +1314,6 @@ map_seq(sl_v rt, sl_v *args, int nargs) · 3 unmodified lines
13141314 sl_v c, v = applyn(pargs);
13151315 POPN(pargs+1);
13161316 switch(rtype){
1317− default:
1318− PUSH(v);
1319− break;
1320− case RT_NIL:
1321− break;
1322− case RT_TBL:
1323− PUSH(car(v));
1324− PUSH(cdr(v));
1325− break;
13261317 case RT_LIST:
13271318 sl_gc_handle(&v);
13281319 c = alloc_cons();
@@ -1335,6 +1326,15 @@ map_seq(sl_v rt, sl_v *args, int nargs) · 6 unmodified lines
13351326 cdr_(sl.stack[k+0]) = c;
13361327 sl.stack[k+0] = c;
13371328 break;
1329+ case RT_NIL:
1330+ break;
1331+ case RT_TBL:
1332+ PUSH(car(v));
1333+ PUSH(cdr(v));
1334+ break;
1335+ default:
1336+ PUSH(v);
1337+ break;
13381338 }
13391339 }
13401340 }
@@ -1575,7 +1575,7 @@ sl_load_system_image(sl_v sys_image_io) · 234 unmodified lines
15751575 sl_v s = car_(e);
15761576 sl_sym *sym = tosym(s);
15771577 e = cdr_(e);
1578− if(sym->binding != sl_unbound)
1578+ if(sl_unlikely(sym->binding != sl_unbound))
15791579 ios_printf(ios_stderr, "%s redefined on boot\n", sym->name);
15801580 sym->binding = car_(e);
15811581 if(isfn(sym->binding) && !isbuiltin(sym->binding) && fn_name(sym->binding))

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