Add validity flags to String

I wish to add @flags : UInt8 to String to memoize: is it ascii? single byte optimizable? Valid utf8?

Such information could be used to speedup searching.

Unfortunately I failed to do it. I found couple of places in compiler infrastructure (LLVM typer and, but it was not enough to compile successfully anything’s (barks on dwarfs or something close to). Looks like there are more places to fix.

Please, suggest where I should look to put more changes?

There is an open issue about this proposal:

I may have a branch with a prototype implementation for this laying around. I’ll have to look that up.

1 Like

Good day.
Did you find the branch?

Sorry, this slipped my attention.

Here it is: Comparing master...feature/string-code_range · crystal-lang/crystal · GitHub

I see: I missed build_string_constant, and didn’t thought about trick in initialize_header.

Will try to cherry-pick your commit and go further.

1 Like

Yeah, that same layout information repated across three different locations is a bit hard to track.
I had previously investigated this for Refactor String header layout reflection by straight-shoota · Pull Request #13335 · crystal-lang/crystal · GitHub, so I know where to look. Not sure what I did back then to find this.