btrfs: calculate hash key only once
@@ -36,10 +36,12 @@ func (b *Driver) makeActive(key, parent string, readonly bool) ([]containerd.Mou
parents = filepath.Join(b.root, "parents")
snapshots = filepath.Join(b.root, "snapshots")
names = filepath.Join(b.root, "names")
- dir = filepath.Join(active, hash(key))
- namep = filepath.Join(names, hash(key))
- parentlink = filepath.Join(parents, hash(key))
- parentp = filepath.Join(snapshots, hash(parent))
+ keyh = hash(key)
+ parenth = hash(parent)
+ dir = filepath.Join(active, keyh)
+ namep = filepath.Join(names, keyh)
+ parentlink = filepath.Join(parents, keyh)
+ parentp = filepath.Join(snapshots, parenth)
)
for _, path := range []string{
@@ -108,12 +110,14 @@ func (b *Driver) Commit(name, key string) error {
snapshots = filepath.Join(b.root, "snapshots")
names = filepath.Join(b.root, "names")
parents = filepath.Join(b.root, "parents")
- dir = filepath.Join(active, hash(key))
- target = filepath.Join(snapshots, hash(name))
- keynamep = filepath.Join(names, hash(key))
- namep = filepath.Join(names, hash(name))
- keyparentlink = filepath.Join(parents, hash(key))
- parentlink = filepath.Join(parents, hash(name))
+ keyh = hash(key)
+ nameh = hash(name)
+ dir = filepath.Join(active, keyh)
+ target = filepath.Join(snapshots, nameh)
+ keynamep = filepath.Join(names, keyh)
+ namep = filepath.Join(names, nameh)
+ keyparentlink = filepath.Join(parents, keyh)
+ parentlink = filepath.Join(parents, nameh)
)
info, err := btrfs.SubvolInfo(dir)
