Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove string(::Union{ByteString,Char}...) method #20

Merged
merged 1 commit into from
May 26, 2017

Conversation

martinholters
Copy link
Contributor

Given how long #8 has been dormant, I propose this simple fix. For string(::ByteString...), the dedicated method above the deleted one is used. For string(::Char...) the method from Base is used (that previously was the cause of the ambiguity). For a mixture of ByteString and Char arguments, the string(::Any...) fallback is used, which should give the correct result, but might be a bit slower (though I haven't checked this).

@martinholters
Copy link
Contributor Author

Any objections here? Otherwise, I'd like to see this merged so that progress can continue on JuliaLang/julia#21965 and JuliaLang/julia#21892.

@martinholters
Copy link
Contributor Author

I did this simple benchmark:

@benchmark string('a', $(ASCIIString("benchmark"^100)))

Run-time was increased from ~185ns to ~740ns. Are there any uses of LegacyStrings out there which are performance critical? Then we could consider adding

string(a::Char...) = invoke(string, Tuple{Vararg{Union{Char,String}}}, a...)

instead of removing the offending method, but that is a bit fragile with respect to changes in Base. Opinions?

@stevengj
Copy link
Member

We shouldn't use invoke. I doubt it is worth optimizing this

@martinholters
Copy link
Contributor Author

So... Merge as is?

@stevengj stevengj merged commit 111de11 into JuliaStrings:master May 26, 2017
@martinholters martinholters deleted the mh/fix_ambiguity branch May 26, 2017 17:35
@martinholters
Copy link
Contributor Author

Thanks. Can we get a new version tagged, too?

@stevengj
Copy link
Member

Tagged v0.2.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants