Avoid redundant digest cast and parse operations
Problem
While working on the garbage collector sweep optimization for S3 (#10 (closed)) I noticed a redundant digest cast/parse operation being performed for all blobs eligible for deletion.
In storage.MarkAndSweep
a blob's digest is converted to a string just to be passed as an argument to storage.Vacuum.RemoveBlob
, where it's parsed back to a digest as soon as received. The storage.Vacuum.RemoveBlob
method is only used in one more place, the proxy.NewRegistryPullThroughCache
function, where the same thing happens (digest converted to a string after being received). So we can avoid these conversions.
Solution
Although the performance impact of this is negligible, this is worthy fix. The solution is to pass the digest around as a digest.Digest
, avoiding redundant cast/parse operations to/from string.