PR feeback
This commit is contained in:
parent
05418dd18a
commit
4250d35347
|
|
@ -1,7 +1,6 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.Server.Kestrel.Extensions;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
|
||||
namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||
|
|
@ -587,10 +586,25 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
}
|
||||
}
|
||||
|
||||
private static int BitCount(long value)
|
||||
{
|
||||
// see https://github.com/dotnet/corefx/blob/master/src/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/BitArithmetic.cs
|
||||
|
||||
const ulong Mask01010101 = 0x5555555555555555UL;
|
||||
const ulong Mask00110011 = 0x3333333333333333UL;
|
||||
const ulong Mask00001111 = 0x0F0F0F0F0F0F0F0FUL;
|
||||
const ulong Mask00000001 = 0x0101010101010101UL;
|
||||
|
||||
var v = (ulong)value;
|
||||
|
||||
v = v - ((v >> 1) & Mask01010101);
|
||||
v = (v & Mask00110011) + ((v >> 2) & Mask00110011);
|
||||
return (int)(unchecked(((v + (v >> 4)) & Mask00001111) * Mask00000001) >> 56);
|
||||
}
|
||||
|
||||
protected override int GetCountFast()
|
||||
{
|
||||
return _bits.BitCount() + (MaybeUnknown?.Count ?? 0);
|
||||
return BitCount(_bits) + (MaybeUnknown?.Count ?? 0);
|
||||
}
|
||||
|
||||
protected override StringValues GetValueFast(string key)
|
||||
|
|
@ -5414,10 +5428,25 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
}
|
||||
}
|
||||
|
||||
private static int BitCount(long value)
|
||||
{
|
||||
// see https://github.com/dotnet/corefx/blob/master/src/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/BitArithmetic.cs
|
||||
|
||||
const ulong Mask01010101 = 0x5555555555555555UL;
|
||||
const ulong Mask00110011 = 0x3333333333333333UL;
|
||||
const ulong Mask00001111 = 0x0F0F0F0F0F0F0F0FUL;
|
||||
const ulong Mask00000001 = 0x0101010101010101UL;
|
||||
|
||||
var v = (ulong)value;
|
||||
|
||||
v = v - ((v >> 1) & Mask01010101);
|
||||
v = (v & Mask00110011) + ((v >> 2) & Mask00110011);
|
||||
return (int)(unchecked(((v + (v >> 4)) & Mask00001111) * Mask00000001) >> 56);
|
||||
}
|
||||
|
||||
protected override int GetCountFast()
|
||||
{
|
||||
return _bits.BitCount() + (MaybeUnknown?.Count ?? 0);
|
||||
return BitCount(_bits) + (MaybeUnknown?.Count ?? 0);
|
||||
}
|
||||
|
||||
protected override StringValues GetValueFast(string key)
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
namespace Microsoft.AspNet.Server.Kestrel.Extensions
|
||||
{
|
||||
public static class LongExtensions
|
||||
{
|
||||
public static int BitCount(this long value)
|
||||
{
|
||||
// see https://github.com/dotnet/corefx/blob/master/src/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/BitArithmetic.cs
|
||||
|
||||
const ulong Mask01010101 = 0x5555555555555555UL;
|
||||
const ulong Mask00110011 = 0x3333333333333333UL;
|
||||
const ulong Mask00001111 = 0x0F0F0F0F0F0F0F0FUL;
|
||||
const ulong Mask00000001 = 0x0101010101010101UL;
|
||||
|
||||
var v = (ulong)value;
|
||||
|
||||
v = v - ((v >> 1) & Mask01010101);
|
||||
v = (v & Mask00110011) + ((v >> 2) & Mask00110011);
|
||||
return (int)(unchecked(((v + (v >> 4)) & Mask00001111) * Mask00000001) >> 56);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -167,7 +167,6 @@ namespace Microsoft.AspNet.Server.Kestrel.GeneratedCode
|
|||
return $@"
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.Server.Kestrel.Extensions;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
|
||||
namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||
|
|
@ -193,10 +192,25 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
}}
|
||||
}}
|
||||
")}
|
||||
private static int BitCount(long value)
|
||||
{{
|
||||
// see https://github.com/dotnet/corefx/blob/master/src/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/BitArithmetic.cs
|
||||
|
||||
const ulong Mask01010101 = 0x5555555555555555UL;
|
||||
const ulong Mask00110011 = 0x3333333333333333UL;
|
||||
const ulong Mask00001111 = 0x0F0F0F0F0F0F0F0FUL;
|
||||
const ulong Mask00000001 = 0x0101010101010101UL;
|
||||
|
||||
var v = (ulong)value;
|
||||
|
||||
v = v - ((v >> 1) & Mask01010101);
|
||||
v = (v & Mask00110011) + ((v >> 2) & Mask00110011);
|
||||
return (int)(unchecked(((v + (v >> 4)) & Mask00001111) * Mask00000001) >> 56);
|
||||
}}
|
||||
|
||||
protected override int GetCountFast()
|
||||
{{
|
||||
return _bits.BitCount() + (MaybeUnknown?.Count ?? 0);
|
||||
return BitCount(_bits) + (MaybeUnknown?.Count ?? 0);
|
||||
}}
|
||||
|
||||
protected override StringValues GetValueFast(string key)
|
||||
|
|
|
|||
Loading…
Reference in New Issue