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
| IntPtr pdata = Marshal.AllocHGlobal(Data.Length * sizeof(int)); | |
| int* data = (int*)pdata; | |
| try | |
| { | |
| Marshal.Copy(Data, 0, pdata, Data.Length); | |
| for (int i = 0; i < Data.Length - (BUFFER_SIZE + 1); i += BUFFER_SIZE) | |
| { | |
| int* sub = data + i; | |
| if (sub[BUFFER_SIZE - 1] != i + BUFFER_SIZE - 1) |
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
| fixed (int* data = &Data[0]) | |
| { | |
| for (int i = 0; i < Data.Length - (BUFFER_SIZE + 1); i += BUFFER_SIZE) | |
| { | |
| int* sub = data + i; | |
| if (sub[BUFFER_SIZE - 1] != i + BUFFER_SIZE - 1) | |
| throw new Exception(); | |
| } | |
| } |
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
| var spanData = new Span<int>(Data); | |
| for (int i = 0; i < Data.Length - (BUFFER_SIZE + 1); i += BUFFER_SIZE) | |
| { | |
| var subSpan = spanData.Slice(i, BUFFER_SIZE); | |
| if (subSpan[BUFFER_SIZE - 1] != i + BUFFER_SIZE - 1) | |
| throw new Exception(); | |
| } |
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
| var subArray = new int[BUFFER_SIZE]; | |
| for (int i = 0; i < Data.Length - (BUFFER_SIZE + 1); i += BUFFER_SIZE) | |
| { | |
| Array.Copy(Data, i, subArray, 0, BUFFER_SIZE); | |
| if (subArray[subArray.Length - 1] != i + BUFFER_SIZE - 1) | |
| throw new Exception(); // avoid optimization | |
| } |
NewerOlder