Navigation Menu

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-1961] Some collection iterators should be custom types #44570

Closed
gribozavr opened this issue Jul 1, 2016 · 4 comments
Closed

[SR-1961] Some collection iterators should be custom types #44570

gribozavr opened this issue Jul 1, 2016 · 4 comments
Assignees
Labels
affects ABI Flag: Affects ABI good first issue Good for newcomers improvement standard library Area: Standard library umbrella

Comments

@gribozavr
Copy link
Collaborator

Previous ID SR-1961
Radar rdar://problem/27119937
Original Reporter @gribozavr
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug, AffectsABI, StarterProposal, swift-evolution-proposal-needed
Assignee @gottesmm
Priority Medium

md5: fca60eed4e979f0b4be234645aaaa9a7

Issue Description:

`String.CharacterView.Iterator` should be a custom type rather than the default, to allow performance optimizations. Audit all other collections for such opportunities.

NOTE: Requires a swift-evolution proposal.

@gottesmm
Copy link
Member

Here is a fleshed out argument:

Iterators are very important for performance since we use them for for loops. By default collections if they do not provide a custom iterator use IndexingIterator as an iterator. IndexingIterator, while only supporting forward movement, is based on indices which possess the ability to go backwards and forwards. For some indices backwards iteration adds unnecessary cost/complexity.

In order to preserve future flexibility, we want to change certain of the types to use custom types that are essentially just IndexingIterator<T>. Then later on when we want to implement these optimizations, we can do it on the custom type underneath the hood without changing the API.

@Dante-Broggi
Copy link
Contributor

Has this been looked into? In the Xcode 9.4.1 toolchain, `String.Iterator` is still `IndexingIterator`

@bob-wilson
Copy link

This was done for everything except ClosedRange in #13489

The ClosedRange change was in #13342

@bob-wilson
Copy link

@airspeedswift Can you comment on the String.Iterator question?

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added good first issue Good for newcomers improvement and removed StarterProposal swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. labels Nov 11, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects ABI Flag: Affects ABI good first issue Good for newcomers improvement standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

5 participants