move vec_add slow case to .c file

This commit is contained in:
dzaima 2021-07-19 04:27:45 +03:00
parent 708e06c0ea
commit 0c04b7e03b
3 changed files with 17 additions and 11 deletions

View File

@ -42,7 +42,7 @@ base: load.o main.o rtwrap.o vm.o ns.o nfns.o
@echo $< | cut -c 11- @echo $< | cut -c 11-
@$(CMD) $@.d -c $< @$(CMD) $@.d -c $<
utils: utf.o hash.o file.o utils: utf.o hash.o file.o mut.o
%.o: ../../src/utils/%.c %.o: ../../src/utils/%.c
@echo $< | cut -c 11- @echo $< | cut -c 11-
@$(CMD) $@.d -c $< @$(CMD) $@.d -c $<

10
src/utils/mut.c Normal file
View File

@ -0,0 +1,10 @@
#include "../core.h"
#include "mut.h"
NOINLINE B vec_addR(B w, B x) {
usz wia = a(w)->ia;
MAKE_MUT(r, wia+1); mut_to(r, el_or(TI(w,elType), selfElType(x)));
mut_copyG(r, 0, w, 0, wia);
mut_setG(r, wia, x);
dec(w);
return mut_fv(r);
}

View File

@ -403,12 +403,8 @@ static inline bool inplace_add(B w, B x) { // fails if fills wouldn't be correct
} }
return false; return false;
} }
B vec_addR(B w, B x);
static B vec_add(B w, B x) { // consumes both; fills may be wrong static B vec_add(B w, B x) { // consumes both; fills may be wrong
if (inplace_add(w, x)) return w; if (inplace_add(w, x)) return w;
usz wia = a(w)->ia; return vec_addR(w, x);
MAKE_MUT(r, wia+1); mut_to(r, el_or(TI(w,elType), selfElType(x)));
mut_copy(r, 0, w, 0, wia);
mut_set(r, wia, x);
dec(w);
return mut_fv(r);
} }