{"action":"created","issue":{"url":"https://api.github.com/repos/apple/swift/issues/1797","repository_url":"https://api.github.com/repos/apple/swift","labels_url":"https://api.github.com/repos/apple/swift/issues/1797/labels{/name}","comments_url":"https://api.github.com/repos/apple/swift/issues/1797/comments","events_url":"https://api.github.com/repos/apple/swift/issues/1797/events","html_url":"https://github.com/apple/swift/pull/1797","id":142796232,"number":1797,"title":"Use a stack allocated _NSContiguousString for hashing and comparison","user":{"login":"aschwaighofer","id":15268288,"avatar_url":"https://avatars.githubusercontent.com/u/15268288?v=3","gravatar_id":"","url":"https://api.github.com/users/aschwaighofer","html_url":"https://github.com/aschwaighofer","followers_url":"https://api.github.com/users/aschwaighofer/followers","following_url":"https://api.github.com/users/aschwaighofer/following{/other_user}","gists_url":"https://api.github.com/users/aschwaighofer/gists{/gist_id}","starred_url":"https://api.github.com/users/aschwaighofer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aschwaighofer/subscriptions","organizations_url":"https://api.github.com/users/aschwaighofer/orgs","repos_url":"https://api.github.com/users/aschwaighofer/repos","events_url":"https://api.github.com/users/aschwaighofer/events{/privacy}","received_events_url":"https://api.github.com/users/aschwaighofer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2016-03-22T22:13:21Z","updated_at":"2016-03-22T23:52:06Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apple/swift/pulls/1797","html_url":"https://github.com/apple/swift/pull/1797","diff_url":"https://github.com/apple/swift/pull/1797.diff","patch_url":"https://github.com/apple/swift/pull/1797.patch"},"body":"\r\n#### What's in this pull request?\r\n\r\nMake String's comparison and hash function faster on platforms that use objc interopt.\r\n\r\nDuring String's hashValue and comparison function we create a\r\n_NSContiguousString instance to call Foundation's hash/compare function. This is\r\nexpensive because we have allocate and deallocate a short lived object on the\r\nheap (and deallocation for Swift objects is expensive).  Instead, allocate this\r\nobject on the stack in the runtime.\r\n\r\nTested by existing String tests.\r\n\r\nWe should see some nice performance improvements for string comparison and\r\ndictionary benchmarks.\r\n\r\nHere is what I measured at -O on my machine\r\n\r\nName                          Speedup\r\nDictionary                      2.16x\r\nDictionary2                     1.47x\r\nDictionary2OfObjects            1.21x\r\nDictionary3                     1.55x\r\nDictionary3OfObjects            1.44x\r\nDictionaryOfObjects             1.42x\r\nSuperChars                      1.66x\r\n\r\nrdar://22173647"},"comment":{"url":"https://api.github.com/repos/apple/swift/issues/comments/200083350","html_url":"https://github.com/apple/swift/pull/1797#issuecomment-200083350","issue_url":"https://api.github.com/repos/apple/swift/issues/1797","id":200083350,"user":{"login":"jrose-apple","id":15097531,"avatar_url":"https://avatars.githubusercontent.com/u/15097531?v=3","gravatar_id":"","url":"https://api.github.com/users/jrose-apple","html_url":"https://github.com/jrose-apple","followers_url":"https://api.github.com/users/jrose-apple/followers","following_url":"https://api.github.com/users/jrose-apple/following{/other_user}","gists_url":"https://api.github.com/users/jrose-apple/gists{/gist_id}","starred_url":"https://api.github.com/users/jrose-apple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrose-apple/subscriptions","organizations_url":"https://api.github.com/users/jrose-apple/orgs","repos_url":"https://api.github.com/users/jrose-apple/repos","events_url":"https://api.github.com/users/jrose-apple/events{/privacy}","received_events_url":"https://api.github.com/users/jrose-apple/received_events","type":"User","site_admin":false},"created_at":"2016-03-22T23:52:06Z","updated_at":"2016-03-22T23:52:06Z","body":"The empty array case (a) is a singleton value of a simpler type and (b) should go away when we have stronger constant optimization (i.e. when we can just do it as `let _swiftEmptyArrayStorage = EmptyArrayStorage()` in Swift)."}}