{"action":"created","issue":{"url":"https://api.github.com/repos/apple/swift/issues/1194","repository_url":"https://api.github.com/repos/apple/swift","labels_url":"https://api.github.com/repos/apple/swift/issues/1194/labels{/name}","comments_url":"https://api.github.com/repos/apple/swift/issues/1194/comments","events_url":"https://api.github.com/repos/apple/swift/issues/1194/events","html_url":"https://github.com/apple/swift/pull/1194","id":131176664,"number":1194,"title":"[SR-610][stdlib] Use SequenceType._initializeTo where possible","user":{"login":"lorentey","id":608696,"avatar_url":"https://avatars.githubusercontent.com/u/608696?v=3","gravatar_id":"","url":"https://api.github.com/users/lorentey","html_url":"https://github.com/lorentey","followers_url":"https://api.github.com/users/lorentey/followers","following_url":"https://api.github.com/users/lorentey/following{/other_user}","gists_url":"https://api.github.com/users/lorentey/gists{/gist_id}","starred_url":"https://api.github.com/users/lorentey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lorentey/subscriptions","organizations_url":"https://api.github.com/users/lorentey/orgs","repos_url":"https://api.github.com/users/lorentey/repos","events_url":"https://api.github.com/users/lorentey/events{/privacy}","received_events_url":"https://api.github.com/users/lorentey/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/apple/swift/labels/performance","name":"performance","color":"0052cc"}],"state":"open","locked":false,"assignee":{"login":"dabrahams","id":44065,"avatar_url":"https://avatars.githubusercontent.com/u/44065?v=3","gravatar_id":"","url":"https://api.github.com/users/dabrahams","html_url":"https://github.com/dabrahams","followers_url":"https://api.github.com/users/dabrahams/followers","following_url":"https://api.github.com/users/dabrahams/following{/other_user}","gists_url":"https://api.github.com/users/dabrahams/gists{/gist_id}","starred_url":"https://api.github.com/users/dabrahams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dabrahams/subscriptions","organizations_url":"https://api.github.com/users/dabrahams/orgs","repos_url":"https://api.github.com/users/dabrahams/repos","events_url":"https://api.github.com/users/dabrahams/events{/privacy}","received_events_url":"https://api.github.com/users/dabrahams/received_events","type":"User","site_admin":false},"milestone":null,"comments":33,"created_at":"2016-02-03T22:39:50Z","updated_at":"2016-03-05T03:55:21Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apple/swift/pulls/1194","html_url":"https://github.com/apple/swift/pull/1194","diff_url":"https://github.com/apple/swift/pull/1194.diff","patch_url":"https://github.com/apple/swift/pull/1194.patch"},"body":"(This is an updated version of PR #1084.)\r\n\r\nChange the `SequenceType._initializeTo` entry point to support memory safety better,\r\nand use it in more places where `Array` elements are initialized in bulk:\r\n- Conversion of sequences and collections to `Array`\r\n- `<ArrayType> += <SequenceType>`\r\n- `ArrayType.replaceRange` (when used for insertion)\r\n\r\nThe speedup achieved is highly sensitive to the mood of the optimizer. The most remarkable result is that insertion of an `Array` into another `Array` can be 4-35x faster depending on the element type. Besides `Array`, `ArraySlice` and `ContiguousArray` also have custom `_initializeTo` implementations, but interestingly, only `Array` seems to be meaningfully impacted by these changes. (The behavior of the\r\noptimizer can be highly unintuitive, making attempts at micro-optimization less useful; see SR-653.)\r\n\r\nWhen `_initializeTo` isn't available, prefer `Generator` to looping over index ranges when iterating over elements of a collection. This speeds up the above operations for collections with complex indexes. \r\nFor example, operations on standard hashed collections typically improve by about 10-40%.\r\n"},"comment":{"url":"https://api.github.com/repos/apple/swift/issues/comments/192565212","html_url":"https://github.com/apple/swift/pull/1194#issuecomment-192565212","issue_url":"https://api.github.com/repos/apple/swift/issues/1194","id":192565212,"user":{"login":"lorentey","id":608696,"avatar_url":"https://avatars.githubusercontent.com/u/608696?v=3","gravatar_id":"","url":"https://api.github.com/users/lorentey","html_url":"https://github.com/lorentey","followers_url":"https://api.github.com/users/lorentey/followers","following_url":"https://api.github.com/users/lorentey/following{/other_user}","gists_url":"https://api.github.com/users/lorentey/gists{/gist_id}","starred_url":"https://api.github.com/users/lorentey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lorentey/subscriptions","organizations_url":"https://api.github.com/users/lorentey/orgs","repos_url":"https://api.github.com/users/lorentey/repos","events_url":"https://api.github.com/users/lorentey/events{/privacy}","received_events_url":"https://api.github.com/users/lorentey/received_events","type":"User","site_admin":false},"created_at":"2016-03-05T03:55:21Z","updated_at":"2016-03-05T03:55:21Z","body":"Good question! Is there a specific statistic I should look at?\r\n\r\nFor what it's worth, `Benchmark_O` grows from 951568 to 956352; the delta is 4784 bytes, or about +0.5%. `libswiftCore.dylib` for x86-64 gets from 3783984 to 3790712 (6728 bytes, +0.18%)."}}