Skip to content

Implement hasPrefix and hasSuffix in Swift #737

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

Closed
wants to merge 1 commit into from
Closed

Implement hasPrefix and hasSuffix in Swift #737

wants to merge 1 commit into from

Conversation

alblue
Copy link
Contributor

@alblue alblue commented Dec 22, 2015

Teach the non-Objective-C implementation how to calculate hasPrefix
and hasSuffix on String data, by using the characters view to step
through the comparison and current string at the same time. The
performance of this will be capped at O(N) in the length of the
compared String, provided that startIndex and endIndex are O(1).

Note that the Objective-C implementation performs NFD normalisation,
which is not done in this implementation.

Bug: SR-337

Teach the non-Objective-C implementation how to calculate hasPrefix
and hasSuffix on String data, by using the characters view to step
through the comparison and current string at the same time. The
performance of this will be capped at O(N) in the length of the
compared String, provided that startIndex and endIndex are O(1).

Note that the Objective-C implementation performs NFD normalisation,
which is not done in this implementation.

Bug: SR-337
@gribozavr
Copy link
Contributor

Thank you for your patch. Please take a look at #630, #629 and #440. Comparing characters one by one is not Unicode-correct.

@gribozavr gribozavr closed this Dec 23, 2015
@gribozavr
Copy link
Contributor

Please feel free to submit another PR with a Unicode-correct one.

@alblue alblue deleted the SR-337 branch December 1, 2016 11:43
kateinoigakukun pushed a commit to kateinoigakukun/swift that referenced this pull request Sep 7, 2020
[pull] swiftwasm-release/5.3 from release/5.3
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