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

[SR-12068] Swift.String version getLineStart(_:end:contentsEnd:for) does not accept nil for parameters #4482

Open
swift-ci opened this issue Jan 23, 2020 · 1 comment

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-12068
Radar rdar://problem/58997118
Original Reporter 1024jp (JIRA User)
Type Bug
Environment

Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15)
Target: x86_64-apple-darwin19.2.0
macOS: 10.15.2 (19C57)
Xcode: 11.3.1 (11C504)

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee None
Priority Medium

md5: f54a27386cf85cdae238ae154fefd318

Issue Description:

Description

Swift.String has the method getLineStart(_:end:contentsEnd:for:) that is corresponding to the same name method in NSString to get the character indexes for its line boundary.

Regarding NSString, this method has a performance advantage compared with lineRange(for:) by passing nil to one or two of the first three parameters, because then, the method doesn't try finding those boundaries. This characteristic is mentioned also in the reference. However, in the Swift.String version, it accepts only non-optional UnsafeMutablePointer<Self.Index>; so there is no way to get only a single boundary of a line range.

This is actually not a bug but undesirable behavior (so please change the issue type if it's wrong). The same issue exists also in getParagraphStart(_:end:contentsEnd:for:).

Expected Result

The parameters start, end, and contentsEnd accept nil so that the method can skip finding needless indexes.

@beccadax
Copy link
Contributor

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants