Move alloc/copy out of lock.
authorTom Clegg <tom@tomclegg.ca>
Thu, 17 Jun 2021 15:13:13 +0000 (11:13 -0400)
committerTom Clegg <tom@tomclegg.ca>
Thu, 17 Jun 2021 15:13:13 +0000 (11:13 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

tilelib.go

index 8960d0e86d8659bf94335ab0bb86b8b5c4aced11..cc4e5c2a60dabb32b0e4afac9f0231f8bf67bea5 100644 (file)
@@ -713,11 +713,12 @@ func (tilelib *tileLibrary) getRef(tag tagID, seq []byte) tileLibRef {
        vlock.Unlock()
 
        if tilelib.retainTileSequences && !dropSeq {
+               seqCopy := append([]byte(nil), seq...)
                tilelib.mtx.Lock()
                if tilelib.seq == nil {
                        tilelib.seq = map[[blake2b.Size256]byte][]byte{}
                }
-               tilelib.seq[seqhash] = append([]byte(nil), seq...)
+               tilelib.seq[seqhash] = seqCopy
                tilelib.mtx.Unlock()
        }