savi-lang / savi

A fast language for programmers who are passionate about their craft.
BSD 3-Clause "New" or "Revised" License
155 stars 12 forks source link

Efficiently encode string slices (`String'val`) as FAT pointer #337

Open mneumann opened 1 year ago

mneumann commented 1 year ago

In case Savi gets FAT pointers, could a string slice which String'val effectively is, be encoded more efficiently by using a special encoding for the vtable pointer to include the length of the string and the pointer itself to point directly to the string data?

This would make any string slicing or parsing operations be very efficient (similar to Rust), as no allocation would be required anymore when creating a new slice. The length of a string slice encoded as such has to be limited to less than 64-bits.

The same could be done with Array slices.