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-3655] Bridging from NSIndexPath to IndexPath should not malloc #3896

Closed
phausler opened this issue Jan 17, 2017 · 2 comments
Closed

[SR-3655] Bridging from NSIndexPath to IndexPath should not malloc #3896

phausler opened this issue Jan 17, 2017 · 2 comments

Comments

@phausler
Copy link
Member

Previous ID SR-3655
Radar rdar://problem/28207534
Original Reporter @phausler
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug, Performance, SDKOverlay
Assignee @phausler
Priority Medium

md5: af451f507d3374f2c3970d7aec78113b

Issue Description:

IndexPath._unconditionallyBridgeFromObjectiveC calls to init(nsIndexPath:) which calls malloc unconditionally in all cases. This is wasteful since we are already allocating an array to store the indicies.

100000 calls of let _ = path as IndexPath with path defined as let path = NSIndexPath(forItem: 5, inSection: 6)
min: 0.000388
max: 0.339831
avg: 0.000594
dev: 0.001665
med: 0.000556

It seems that any array backing more than zero elements will call malloc up to two times when bridging. This behavior is wasteful and we can probably do much better in the round trip.

@swift-ci
Copy link
Contributor

Comment by Stephan Tolksdorf (JIRA)

Thanks for tackling this!

This issue was also discussed a bit last year on the swift-corelibs-dev mailing list: https://lists.swift.org/pipermail/swift-corelibs-dev/Week-of-Mon-20160801/thread.html#826

@tkremenek
Copy link
Member

This was resolved by apple/swift@ffc594b

@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
This issue was closed.
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

3 participants