schovi / baked_file_system

Virtual File System for Crystal language. Embedding your assets into final binary.
MIT License
177 stars 18 forks source link

Use byte encoding as Crystal string instead of Base64 #12

Closed straight-shoota closed 6 years ago

straight-shoota commented 6 years ago

Crystal allows to put arbitrary byte values into strings even if they aren't valid UTF-8.

This is 30% more space-efficient than Base64 encoding which translates directly to the size of the compiled binary.

Unfortunately there exists no literal for Slice right now (but there is a discussion about this in crystal-lang/crystal#2886) so we need to resort to strings for this. It is a bit hacky but look like it works 👍

It also includes a refactoring of the API exposed by BakedFile, including making it an IO and deprecating several methods that can be replaced by using the file as an IO.

Based on #11

straight-shoota commented 6 years ago

ping @schovi

straight-shoota commented 6 years ago

@schovi Would you mind taking a look at this as well? =)

schovi commented 6 years ago

@straight-shoota awesome! Thanks for kick me forward. I have some ideas and wip things there :)