{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/coreclr/issues/1816","labels_url":"https://api.github.com/repos/dotnet/coreclr/issues/1816/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/coreclr/issues/1816/comments","events_url":"https://api.github.com/repos/dotnet/coreclr/issues/1816/events","html_url":"https://github.com/dotnet/coreclr/pull/1816","id":112476690,"number":1816,"title":"Improve string.{Last}IndexOf perf on Unix for Ordinal/OrdinalIgnoreCase","user":{"login":"stephentoub","id":2642209,"avatar_url":"https://avatars.githubusercontent.com/u/2642209?v=3","gravatar_id":"","url":"https://api.github.com/users/stephentoub","html_url":"https://github.com/stephentoub","followers_url":"https://api.github.com/users/stephentoub/followers","following_url":"https://api.github.com/users/stephentoub/following{/other_user}","gists_url":"https://api.github.com/users/stephentoub/gists{/gist_id}","starred_url":"https://api.github.com/users/stephentoub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephentoub/subscriptions","organizations_url":"https://api.github.com/users/stephentoub/orgs","repos_url":"https://api.github.com/users/stephentoub/repos","events_url":"https://api.github.com/users/stephentoub/events{/privacy}","received_events_url":"https://api.github.com/users/stephentoub/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/coreclr/labels/2%20-%20In%20Progress","name":"2 - In Progress","color":"ededed"},{"url":"https://api.github.com/repos/dotnet/coreclr/labels/cla-already-signed","name":"cla-already-signed","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-10-20T22:55:28Z","updated_at":"2015-10-22T20:47:48Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/dotnet/coreclr/pulls/1816","html_url":"https://github.com/dotnet/coreclr/pull/1816","diff_url":"https://github.com/dotnet/coreclr/pull/1816.diff","patch_url":"https://github.com/dotnet/coreclr/pull/1816.patch"},"body":"Our current implementation of IndexOfOrdinal for strings on Unix uses Substring to get the piece of the source string we care about; this results in an unnecessary allocation / string copy.  When using OrdinalIgnoreCase, we also convert both the source and search strings to upper-case using ToUpperInvariant, resulting in more allocations.  And our LastIndexOfOrdinal implementation delegates to IndexOfOrdinal repeatedly, incurring such allocations potentially multiple times.\r\n\r\nThis change reimplements Ordinal searching in managed code to not use Substring, and it implements OrdinalIgnoreCase searching via new functions exposed in the native globalization shim, so as to use ICU without having to make managed/native transitions for each character.\r\n\r\nWith the changes, {Last}IndexOf with Ordinal/OrdinalIgnoreCase are now allocateion-free (as you'd expect), and throughput when startIndex/count and/or OrdinalIgnoreCase are used is increased significantly, on my machine anywhere from 20% to 3x, depending on the inputs.\r\n\r\ncc: @ellismg, @tarekgh "},"comment":{"url":"https://api.github.com/repos/dotnet/coreclr/issues/comments/150351710","html_url":"https://github.com/dotnet/coreclr/pull/1816#issuecomment-150351710","issue_url":"https://api.github.com/repos/dotnet/coreclr/issues/1816","id":150351710,"user":{"login":"stephentoub","id":2642209,"avatar_url":"https://avatars.githubusercontent.com/u/2642209?v=3","gravatar_id":"","url":"https://api.github.com/users/stephentoub","html_url":"https://github.com/stephentoub","followers_url":"https://api.github.com/users/stephentoub/followers","following_url":"https://api.github.com/users/stephentoub/following{/other_user}","gists_url":"https://api.github.com/users/stephentoub/gists{/gist_id}","starred_url":"https://api.github.com/users/stephentoub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephentoub/subscriptions","organizations_url":"https://api.github.com/users/stephentoub/orgs","repos_url":"https://api.github.com/users/stephentoub/repos","events_url":"https://api.github.com/users/stephentoub/events{/privacy}","received_events_url":"https://api.github.com/users/stephentoub/received_events","type":"User","site_admin":false},"created_at":"2015-10-22T20:47:48Z","updated_at":"2015-10-22T20:47:48Z","body":"Thanks, Matt."}}