Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

Commit

Permalink
Pass StringValues via in (#2295)
Browse files Browse the repository at this point in the history
  • Loading branch information
benaadams authored and davidfowl committed Mar 1, 2018
1 parent 2c108d9 commit 3004533
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
16 changes: 8 additions & 8 deletions src/Kestrel.Core/Internal/Http/HttpHeaders.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ protected override bool TryGetValueFast(string key, out StringValues value)
return MaybeUnknown?.TryGetValue(key, out value) ?? false;
}

protected override void SetValueFast(string key, StringValues value)
protected override void SetValueFast(string key, in StringValues value)
{
switch (key.Length)
{
Expand Down Expand Up @@ -1600,7 +1600,7 @@ protected override void SetValueFast(string key, StringValues value)
SetValueUnknown(key, value);
}

protected override bool AddValueFast(string key, StringValues value)
protected override bool AddValueFast(string key, in StringValues value)
{
switch (key.Length)
{
Expand Down Expand Up @@ -5411,25 +5411,25 @@ public StringValues HeaderContentLength
}
}

public void SetRawConnection(StringValues value, byte[] raw)
public void SetRawConnection(in StringValues value, byte[] raw)
{
_bits |= 2L;
_headers._Connection = value;
_headers._rawConnection = raw;
}
public void SetRawDate(StringValues value, byte[] raw)
public void SetRawDate(in StringValues value, byte[] raw)
{
_bits |= 4L;
_headers._Date = value;
_headers._rawDate = raw;
}
public void SetRawTransferEncoding(StringValues value, byte[] raw)
public void SetRawTransferEncoding(in StringValues value, byte[] raw)
{
_bits |= 64L;
_headers._TransferEncoding = value;
_headers._rawTransferEncoding = raw;
}
public void SetRawServer(StringValues value, byte[] raw)
public void SetRawServer(in StringValues value, byte[] raw)
{
_bits |= 33554432L;
_headers._Server = value;
Expand Down Expand Up @@ -5849,7 +5849,7 @@ protected override bool TryGetValueFast(string key, out StringValues value)
return MaybeUnknown?.TryGetValue(key, out value) ?? false;
}

protected override void SetValueFast(string key, StringValues value)
protected override void SetValueFast(string key, in StringValues value)
{
ValidateHeaderCharacters(value);
switch (key.Length)
Expand Down Expand Up @@ -6154,7 +6154,7 @@ protected override void SetValueFast(string key, StringValues value)
SetValueUnknown(key, value);
}

protected override bool AddValueFast(string key, StringValues value)
protected override bool AddValueFast(string key, in StringValues value)
{
ValidateHeaderCharacters(value);
switch (key.Length)
Expand Down
12 changes: 6 additions & 6 deletions src/Kestrel.Core/Internal/Http/HttpHeaders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void Reset()
}

[MethodImpl(MethodImplOptions.NoInlining)]
protected static StringValues AppendValue(StringValues existing, string append)
protected static StringValues AppendValue(in StringValues existing, string append)
{
return StringValues.Concat(existing, append);
}
Expand All @@ -134,10 +134,10 @@ protected virtual int GetCountFast()
protected virtual bool TryGetValueFast(string key, out StringValues value)
{ throw new NotImplementedException(); }

protected virtual void SetValueFast(string key, StringValues value)
protected virtual void SetValueFast(string key, in StringValues value)
{ throw new NotImplementedException(); }

protected virtual bool AddValueFast(string key, StringValues value)
protected virtual bool AddValueFast(string key, in StringValues value)
{ throw new NotImplementedException(); }

protected virtual bool RemoveFast(string key)
Expand Down Expand Up @@ -234,7 +234,7 @@ bool IDictionary<string, StringValues>.TryGetValue(string key, out StringValues
return TryGetValueFast(key, out value);
}

public static void ValidateHeaderCharacters(StringValues headerValues)
public static void ValidateHeaderCharacters(in StringValues headerValues)
{
var count = headerValues.Count;
for (var i = 0; i < count; i++)
Expand All @@ -258,7 +258,7 @@ public static void ValidateHeaderCharacters(string headerCharacters)
}
}

public static unsafe ConnectionOptions ParseConnection(StringValues connection)
public static unsafe ConnectionOptions ParseConnection(in StringValues connection)
{
var connectionOptions = ConnectionOptions.None;

Expand Down Expand Up @@ -360,7 +360,7 @@ public static unsafe ConnectionOptions ParseConnection(StringValues connection)
return connectionOptions;
}

public static unsafe TransferCoding GetFinalTransferCoding(StringValues transferEncoding)
public static unsafe TransferCoding GetFinalTransferCoding(in StringValues transferEncoding)
{
var transferEncodingOptions = TransferCoding.None;

Expand Down
2 changes: 1 addition & 1 deletion src/Kestrel.Core/Internal/Http/HttpRequestHeaders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private static long ParseContentLength(string value)
}

[MethodImpl(MethodImplOptions.NoInlining)]
private void SetValueUnknown(string key, StringValues value)
private void SetValueUnknown(string key, in StringValues value)
{
Unknown[key] = value;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Kestrel.Core/Internal/Http/HttpResponseHeaders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private static long ParseContentLength(string value)
}

[MethodImpl(MethodImplOptions.NoInlining)]
private void SetValueUnknown(string key, StringValues value)
private void SetValueUnknown(string key, in StringValues value)
{
ValidateHeaderCharacters(key);
Unknown[key] = value;
Expand All @@ -93,11 +93,11 @@ internal Enumerator(HttpResponseHeaders collection)
_collection = collection;
_bits = collection._bits;
_state = 0;
_current = default(KeyValuePair<string, StringValues>);
_current = default;
_hasUnknown = collection.MaybeUnknown != null;
_unknownEnumerator = _hasUnknown
? collection.MaybeUnknown.GetEnumerator()
: default(Dictionary<string, StringValues>.Enumerator);
: default;
}

public KeyValuePair<string, StringValues> Current => _current;
Expand Down
6 changes: 3 additions & 3 deletions tools/CodeGenerator/KnownHeaders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ public StringValues Header{header.Identifier}
}}")}
}}")}
{Each(loop.Headers.Where(header => header.EnhancedSetter), header => $@"
public void SetRaw{header.Identifier}(StringValues value, byte[] raw)
public void SetRaw{header.Identifier}(in StringValues value, byte[] raw)
{{
{header.SetBit()};
_headers._{header.Identifier} = value;
Expand Down Expand Up @@ -383,7 +383,7 @@ protected override bool TryGetValueFast(string key, out StringValues value)
return MaybeUnknown?.TryGetValue(key, out value) ?? false;
}}

protected override void SetValueFast(string key, StringValues value)
protected override void SetValueFast(string key, in StringValues value)
{{{(loop.ClassName == "HttpResponseHeaders" ? @"
ValidateHeaderCharacters(value);" : "")}
switch (key.Length)
Expand All @@ -405,7 +405,7 @@ protected override void SetValueFast(string key, StringValues value)
SetValueUnknown(key, value);
}}

protected override bool AddValueFast(string key, StringValues value)
protected override bool AddValueFast(string key, in StringValues value)
{{{(loop.ClassName == "HttpResponseHeaders" ? @"
ValidateHeaderCharacters(value);" : "")}
switch (key.Length)
Expand Down

0 comments on commit 3004533

Please sign in to comment.