diff options
author | Tarek Mahmoud Sayed <tarekms@microsoft.com> | 2019-03-22 15:22:50 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-22 15:22:50 -0700 |
commit | 39b1b6338015c9d6ef193986e0579f0ae0e60566 (patch) | |
tree | b0e62477ba29700fbf7879aad8f830a91a02d860 | |
parent | a63da9e80defe0187d8ee59b9732a978ce4c493e (diff) | |
download | coreclr-39b1b6338015c9d6ef193986e0579f0ae0e60566.tar.gz coreclr-39b1b6338015c9d6ef193986e0579f0ae0e60566.tar.bz2 coreclr-39b1b6338015c9d6ef193986e0579f0ae0e60566.zip |
Apply Optimization in Index.GetOffset suggested by Levi (#23349)
* Apply Optimization in Index.GetOffset suggested by Levi
* Add Comment
* address the feedback
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Index.cs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Index.cs b/src/System.Private.CoreLib/shared/System/Index.cs index 9767b981ef..62d7f3440c 100644 --- a/src/System.Private.CoreLib/shared/System/Index.cs +++ b/src/System.Private.CoreLib/shared/System/Index.cs @@ -103,13 +103,15 @@ namespace System [MethodImpl(MethodImplOptions.AggressiveInlining)] public int GetOffset(int length) { - int offset; - + int offset = _value; if (IsFromEnd) - offset = length - (~_value); - else - offset = _value; + { + // offset = length - (~value) + // offset = length + (~(~value) + 1) + // offset = length + value + 1 + offset += length + 1; + } return offset; } |