Created
July 2, 2020 15:25
-
-
Save mgravell/16ed5c0d21a7dd7dfd75a2a22b865331 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string s = string.Join(",", Enumerable.Repeat("blah", 50)); | |
var charSpan = s.AsSpan(); | |
var vectorized = MemoryMarshal.Cast<char, Vector<ushort>>(charSpan); | |
Console.WriteLine($"vector chunks: " + vectorized.Length); | |
foreach(var v in vectorized) | |
{ | |
if (Vector.EqualsAny(v, spaces)) { ...} | |
} | |
// todo: mop up any remainded | |
// not shown: static readonly Vector<ushort> spaces = new Vector<ushort>(' '); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment