From b7f15b74722ac1065e5c5d7ecac985b3347b4df3 Mon Sep 17 00:00:00 2001 From: EgorBo Date: Sun, 8 Mar 2020 13:59:41 +0300 Subject: [PATCH] Make StandardFormat.ctor inlineable --- .../src/System/Buffers/StandardFormat.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Buffers/StandardFormat.cs b/src/libraries/System.Private.CoreLib/src/System/Buffers/StandardFormat.cs index 24a49838308d76..56fe48f1b93cea 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Buffers/StandardFormat.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Buffers/StandardFormat.cs @@ -52,7 +52,9 @@ namespace System.Buffers /// An optional precision ranging from 0..9 or the special value NoPrecision (the default) public StandardFormat(char symbol, byte precision = NoPrecision) { - if (precision != NoPrecision && precision > MaxPrecision) + // Optimized version of "precision != NoPrecision && precision > MaxPrecision" + // it makes StandardFormat inlinenable + if ((byte)(precision - (MaxPrecision + 1)) < (NoPrecision - (MaxPrecision + 1))) ThrowHelper.ThrowArgumentOutOfRangeException_PrecisionTooLarge(); if (symbol != (byte)symbol) ThrowHelper.ThrowArgumentOutOfRangeException_SymbolDoesNotFit();