carp-lang / Carp

A statically typed lisp, without a GC, for real-time applications.
Apache License 2.0
5.47k stars 173 forks source link

performance: better default string functions #1420

Open scolsen opened 2 years ago

scolsen commented 2 years ago

the default implementations of some string functions can consume a lot of clock cycles, e.g. for large arrays which call the prn implementation for each member, yielding some function call overhead. I think (but I'm not certain)that calling printf directly on members would probably be at least a little more efficient: printf("%d" arr[i]) in the for body opposed to prn(arr[i]).

maybe we could tackle this similarly to blit? if there's an interface a type implements perhaps we can perform some optimization where we inline the printf call or something