Skip to content

Conversation

@allevato
Copy link
Member

@allevato allevato commented Mar 3, 2019

Floating an early sketch of some shared String APIs to improve interop code.

Still some open questions, like:

  • Should this take advantage of ContiguousCollection instead of taking pointers directly (probably)
  • Do we need a method to force a shared string into a native one, thus copying it (probably)

cc @milseman

guard _wholeGuts.isFastUTF8 else {
// TODO: What's the right way to get the pointer for a non-fast-UTF-8
// string here?
return try body(String(self))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine to me. I guess the other option would be to form a foreign string, such as a sliced NSString subclass.

return try body(String(self))
}

return try _wholeGuts.withFastUTF8 { utf8 in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't small-string correct, but small substrings will form small strings, so eager copy is even faster than using __SharedStringStorag. What we'd want to do is check for a contiguous string with a stable pointer.

@karwa
Copy link
Contributor

karwa commented Apr 4, 2020

ping @milseman @allevato

Are there any plans to move this along with a pitch? Would you mind if I wrote one?

@allevato
Copy link
Member Author

allevato commented Apr 6, 2020

@karwa I don't know what @milseman 's plans are, but I haven't had free time lately to work on this so if you'd like to run with it, feel free!

@shahmishal
Copy link
Member

Please update the base branch to main by Oct 5th otherwise the pull request will be closed automatically.

  • How to change the base branch: (Link)
  • More detail about the branch update: (Link)

@shahmishal shahmishal closed this Oct 5, 2020
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.

4 participants