Similar to other complex types like Enum[] and Status[], let's support capacity for performance optimization use cases.
Now the string will already be created by the time it comes to be type checked, so let's first fix that chicken and egg problem with some outside the box thinking. Don't forget, we have Lowkey which gives us access to the "File Load" phase, before any Ruby code has actually been run.
https://ruby-doc.org/core-2.5.7/String.html:
The optional capacity keyword argument specifies the size of the internal buffer. This may improve performance, when the string will be concatenated many times (causing many realloc calls).
https://ruby-doc.org/3.4.1/String.html:
With optional keyword argument capacity, returns a copy of string (or an empty string, if string is not given); the given capacity is advisory only, and may or may not set the size of the internal buffer, which may in turn affect performance
Implementation
String[] complex type
- Performance before and after tests
Similar to other complex types like
Enum[]andStatus[], let's supportcapacityfor performance optimization use cases.Now the string will already be created by the time it comes to be type checked, so let's first fix that chicken and egg problem with some outside the box thinking. Don't forget, we have Lowkey which gives us access to the "File Load" phase, before any Ruby code has actually been run.
https://ruby-doc.org/core-2.5.7/String.html:
https://ruby-doc.org/3.4.1/String.html:
Implementation
String[]complex type