On 6/24/15 12:29 PM, Steven Schveighoffer wrote:

1. Any code that was written to use the string version is currently
passing a string for the extension. Only provide a cached conversion to
string if that is the case (i.e. you have 2 strings passed in), and
we'll be fine for existing code. Store the cached string into one of the
two stored ranges. Don't even bother allowing conversion from non-string
ranges to a string, just don't compile. This solves the space problem.

2. Code that is using the string version can call array, or can
specifically say "string x = ..." instead of "auto x = ..." to avoid
extra checks if they want to squeeze out that little test instruction. I
don't see why we should care about an extra check for code that is
deprecated or undesirable, and I don't see how the extra check is that
bad either.

I really like Adam's idea. A lot.

So I actually implemented this. I made it a std.internal type so it can be used wherever you need to port string concatenation to a chain.

A curious thing though. All the tests for things like:

assert(setExtension("file", "ext") == "file.ext");

do not trigger a call to eager. But this does:

assert(setExtension("file", "ext").array == "file.ext");

This might be a deal breaker, or alternative, I have no clue what's going on here...

The branch is pushed, but I don't know if it's in PR form, especially considering the above. See if it makes sense to everyone, and it's probably got some bugs :)

https://github.com/schveiguy/phobos/tree/setextfix

-Steve

Reply via email to