Skip to content

Commit

Permalink
Cleanup code and make it more performant
Browse files Browse the repository at this point in the history
Description:

   This is to follow up previous checkins and make the code better performant:

   1) When checking the StreamIndex in client manifest, no need to do two round of checks for video/audio streams.
   2) When getting the Storage account's subscriptionId, resourceGroupName and acctName, no need to do string parsing again.
  • Loading branch information
weibz committed Sep 11, 2023
1 parent 1a70d8c commit 86b6430
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 25 deletions.
28 changes: 8 additions & 20 deletions ams/AzureResourceProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,16 @@ public async Task SetStorageResourceGroupsAsync(MediaServicesAccountResource acc
if (mediaServiceResource.GetRawResponse().Status == 200)
{
storageAccounts = mediaServiceResource.Value.Data.StorageAccounts;
if (storageAccounts != null && storageAccounts.Any())

foreach (var storageAccount in storageAccounts)
{
foreach (var storageAccount in storageAccounts)
{
string? storageAccountId = storageAccount.Id;
///subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.storage/storageaccounts/{accountName}
if (!string.IsNullOrEmpty(storageAccountId))
{
string[] parts;
parts = storageAccountId.Split('/');
string resourceGroupName = parts[4];
string storageAccName = parts[8];
string subscriptionId = parts[2];
var resourceGroupId = ResourceGroupResource.CreateResourceIdentifier(
subscriptionId,
resourceGroupName);
var resourceGroup = _armClient.GetResourceGroupResource(resourceGroupId);
_storageResourceGroups.Add(storageAccName, resourceGroup);
}
}
var storageAccountId = storageAccount.Id;
var resourceGroupId = ResourceGroupResource.CreateResourceIdentifier(
storageAccountId.SubscriptionId!,
storageAccountId.ResourceGroupName!);
var resourceGroup = _armClient.GetResourceGroupResource(resourceGroupId);
_storageResourceGroups.Add(storageAccountId.Name, resourceGroup);
}

}
}

Expand Down
6 changes: 1 addition & 5 deletions transform/ShakaPackager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ public ShakaPackager(MigratorOptions options, AssetDetails assetDetails, TransMu
videoStream = stream;
numVideoStreams++;
}
}

foreach (var stream in clientManifest.Streams)
{
if (stream.Type == StreamType.Audio)
else if (stream.Type == StreamType.Audio)
{
audioStream = stream;
numAudioStreams++;
Expand Down

0 comments on commit 86b6430

Please sign in to comment.