Skip to content

Commit

Permalink
reduce number of allocations. (#21243)
Browse files Browse the repository at this point in the history
  • Loading branch information
kasobol-msft authored May 20, 2021
1 parent e943412 commit 48f5961
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions sdk/storage/Azure.Storage.Blobs/src/BlobClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1629,8 +1629,6 @@ internal async Task<Response<BlobContentInfo>> StagedUploadInternal(
.ClientSideEncryptInternal(content, options.Metadata, async, cancellationToken).ConfigureAwait(false);
}

var client = new BlockBlobClient(Uri, ClientConfiguration);

var uploader = GetPartitionedUploader(
transferOptions: options?.TransferOptions ?? default,
operationName: $"{nameof(BlobClient)}.{nameof(Upload)}");
Expand Down Expand Up @@ -1710,11 +1708,24 @@ internal async Task<Response<BlobContentInfo>> StagedUploadInternal(
}
#endregion Upload

private BlockBlobClient _blockBlobClient;

private BlockBlobClient BlockBlobClient
{
get
{
if (_blockBlobClient == null)
{
_blockBlobClient = new BlockBlobClient(Uri, ClientConfiguration);
}
return _blockBlobClient;
}
}

internal PartitionedUploader<BlobUploadOptions, BlobContentInfo> GetPartitionedUploader(
StorageTransferOptions transferOptions,
ArrayPool<byte> arrayPool = null,
string operationName = null)
=> new BlockBlobClient(Uri, ClientConfiguration)
.GetPartitionedUploader(transferOptions, arrayPool, operationName);
=> BlockBlobClient.GetPartitionedUploader(transferOptions, arrayPool, operationName);
}
}

0 comments on commit 48f5961

Please sign in to comment.