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
[SR-3006] CharacterSet should have a way of ensuring the wrapped NSCharacterSet is immutable #3919
Comments
I would hope it's already doing that at bridge-time; otherwise it's not a proper value type. |
Even if just bridging to Obj-C and back (without calling copy) is sufficient (and you're right, it probably should be doing that already), that's still something that shouldn't be required in order to get efficient character sets. |
Ah, right, I forgot about |
I just checked, bridging to Obj-C actually produces an I'll file a separate ticket for this issue, but it does confirm that bridging to Obj-C and back won't "freeze" a |
I filed the followup ticket as SR-9044. I also put a long comment on that ticket that describes a new approach to constructing {{CharacterSet}} that avoids this issue. |
Update: Bridging to Obj-C and back actually should "freeze" it because the act of bridging it back will copy it. Assuming of course that Swift doesn't see |
Additional Detail from JIRA
md5: 0db672c16638232d28397c95f5e0c65c
relates to:
Issue Description:
According to the documentation on
NSMutableCharacterSet
, mutable character sets are less efficient to work with than immutable character sets (assuming no more mutations need to happen), and therefore it recommends callingcopy()
to produce an immutable character set once you've finished mutating it.However, there appears to be no way to get this behavior with
CharacterSet
, short of bridging to Obj-C, copying, and bridging back.To that end, it would seem to be useful for
CharacterSet
to have a method that ensures the wrapped character set is immutable.The text was updated successfully, but these errors were encountered: