Skip to content

Commit cf8f998

Browse files
authored
Minor code optimization. (#9960) (#9998)
1 parent 84f9664 commit cf8f998

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

src/WebJobs.Script.Grpc/MessageExtensions/GrpcMessageConversionExtensions.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,19 @@ internal static async Task<TypedData> ToRpcHttp(this HttpRequest request, ILogge
111111
var http = new RpcHttp()
112112
{
113113
Url = $"{(request.IsHttps ? "https" : "http")}://{request.Host}{request.Path}{request.QueryString}",
114-
Method = request.Method.ToString(),
114+
Method = request.Method,
115115
RawBody = null
116116
};
117117
var typedData = new TypedData
118118
{
119119
Http = http
120120
};
121121

122+
var shouldUseNullableValueDictionary = ShouldUseNullableValueDictionary(capabilities);
122123
foreach (var pair in request.Query)
123124
{
124125
var value = pair.Value.ToString();
125-
if (ShouldUseNullableValueDictionary(capabilities))
126+
if (shouldUseNullableValueDictionary)
126127
{
127128
http.NullableQuery.Add(pair.Key, new NullableString { Value = value });
128129
}
@@ -137,7 +138,7 @@ internal static async Task<TypedData> ToRpcHttp(this HttpRequest request, ILogge
137138

138139
foreach (var pair in request.Headers)
139140
{
140-
if (ShouldUseNullableValueDictionary(capabilities))
141+
if (shouldUseNullableValueDictionary)
141142
{
142143
http.NullableHeaders.Add(pair.Key.ToLowerInvariant(), new NullableString { Value = pair.Value.ToString() });
143144
}
@@ -159,7 +160,7 @@ internal static async Task<TypedData> ToRpcHttp(this HttpRequest request, ILogge
159160
{
160161
if (pair.Value != null)
161162
{
162-
if (ShouldUseNullableValueDictionary(capabilities))
163+
if (shouldUseNullableValueDictionary)
163164
{
164165
http.NullableParams.Add(pair.Key, new NullableString { Value = pair.Value.ToString() });
165166
}

src/WebJobs.Script/Extensions/HttpRequestExtensions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ public static async Task<byte[]> GetRequestBodyAsBytesAsync(this HttpRequest req
121121

122122
byte[] bytes;
123123
using (var ms = new MemoryStream())
124-
using (var reader = new StreamReader(ms))
125124
{
126125
await request.Body.CopyToAsync(ms);
127126
bytes = ms.ToArray();

src/WebJobs.Script/Host/FunctionMetadataManager.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public class FunctionMetadataManager : IFunctionMetadataManager
2424
private const string _functionConfigurationErrorMessage = "Unable to determine the primary function script.Make sure atleast one script file is present.Try renaming your entry point script to 'run' or alternatively you can specify the name of the entry point script explicitly by adding a 'scriptFile' property to your function metadata.";
2525
private const string _metadataProviderName = "Custom";
2626
private readonly IServiceProvider _serviceProvider;
27-
private readonly ILoggerFactory _loggerFactory;
2827
private IFunctionMetadataProvider _functionMetadataProvider;
2928
private bool _isHttpWorker;
3029
private IEnvironment _environment;
@@ -42,12 +41,11 @@ public FunctionMetadataManager(IOptions<ScriptJobHostOptions> scriptOptions, IFu
4241
_scriptOptions = scriptOptions;
4342
_serviceProvider = scriptHostManager as IServiceProvider;
4443
_functionMetadataProvider = functionMetadataProvider;
45-
_loggerFactory = loggerFactory;
4644
_logger = loggerFactory.CreateLogger(LogCategories.Startup);
4745
_isHttpWorker = httpWorkerOptions?.Value?.Description != null;
4846
_environment = environment;
4947

50-
// Every time script host is re-intializing, we also need to re-initialize
48+
// Every time script host is re-initializing, we also need to re-initialize
5149
// services that change with the scope of the script host.
5250
scriptHostManager.ActiveHostChanged += (s, e) =>
5351
{
@@ -82,7 +80,7 @@ public bool TryGetFunctionMetadata(string functionName, out FunctionMetadata fun
8280
/// <param name="forceRefresh">Forces reload from all providers.</param>
8381
/// <param name="applyAllowList">Apply functions allow list filter.</param>
8482
/// <param name="includeCustomProviders">Include any metadata provided by IFunctionProvider when loading the metadata</param>
85-
/// <returns> An Immmutable array of FunctionMetadata.</returns>
83+
/// <returns> An Immutable array of FunctionMetadata.</returns>
8684
public ImmutableArray<FunctionMetadata> GetFunctionMetadata(bool forceRefresh, bool applyAllowList = true, bool includeCustomProviders = true, IList<RpcWorkerConfig> workerConfigs = null)
8785
{
8886
if (forceRefresh || _servicesReset || _functionMetadataArray.IsDefaultOrEmpty)

0 commit comments

Comments
 (0)