The Free Software Media System - Server Backend & API
Multiplication is faster than bit shifting
Bond_009593107e19085
diff --git a/MediaBrowser.Common/Hex.cs b/MediaBrowser.Common/Hex.csindex 6c86e4e6d0..b2d9aea3a7 100644--- a/MediaBrowser.Common/Hex.cs+++ b/MediaBrowser.Common/Hex.cs@@ -81,7 +81,7 @@ namespace MediaBrowser.Commonbreak; // Unreachable}- bytes[j] = (byte)((a << 4) | b);+ bytes[j] = (byte)((a * 16) | b);}return bytes;diff --git a/benches/Jellyfin.Common.Benches/HexDecodeBenches.cs b/benches/Jellyfin.Common.Benches/HexDecodeBenches.csindex 2efe5273f7..5cd47202c9 100644--- a/benches/Jellyfin.Common.Benches/HexDecodeBenches.cs+++ b/benches/Jellyfin.Common.Benches/HexDecodeBenches.cs@@ -9,7 +9,7 @@ namespace Jellyfin.Common.Benches[MemoryDiagnoser]public class HexDecodeBenches{- [Params(0, 10, 100, 1000, 10000, 1000000)]+ [Params(/*0,*/ 10, 100, 1000, 10000, 1000000)]public int N { get; set; }private string data;@@ -40,6 +40,9 @@ namespace Jellyfin.Common.Benchespublic byte[] Decode() => Hex.Decode(data);[Benchmark]+ public byte[] Decode2() => Hex.Decode2(data);++ //[Benchmark]public byte[] DecodeSubString() => DecodeSubString(data);}}diff --git a/benches/Jellyfin.Common.Benches/Program.cs b/benches/Jellyfin.Common.Benches/Program.csindex b218b0dc10..e7d51c1b54 100644--- a/benches/Jellyfin.Common.Benches/Program.cs+++ b/benches/Jellyfin.Common.Benches/Program.cs@@ -7,7 +7,7 @@ namespace Jellyfin.Common.Benches{public static void Main(string[] args){- _ = BenchmarkRunner.Run<HexEncodeBenches>();+ //_ = BenchmarkRunner.Run<HexEncodeBenches>();_ = BenchmarkRunner.Run<HexDecodeBenches>();}}