forked from TrueCloudLab/frostfs-node
[#31] fstree: Optimize treePath
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
dee4498c1e
commit
204cd3a11c
1 changed files with 8 additions and 6 deletions
|
@ -172,17 +172,19 @@ func (t *FSTree) iterate(depth uint64, curPath []string, prm common.IteratePrm)
|
||||||
func (t *FSTree) treePath(addr oid.Address) string {
|
func (t *FSTree) treePath(addr oid.Address) string {
|
||||||
sAddr := stringifyAddress(addr)
|
sAddr := stringifyAddress(addr)
|
||||||
|
|
||||||
dirs := make([]string, 0, t.Depth+1+1) // 1 for root, 1 for file
|
var sb strings.Builder
|
||||||
dirs = append(dirs, t.RootPath)
|
sb.Grow(len(t.RootPath) + len(sAddr) + int(t.Depth) + 1)
|
||||||
|
sb.WriteString(t.RootPath)
|
||||||
|
|
||||||
for i := 0; uint64(i) < t.Depth; i++ {
|
for i := 0; uint64(i) < t.Depth; i++ {
|
||||||
dirs = append(dirs, sAddr[:t.DirNameLen])
|
sb.WriteRune(filepath.Separator)
|
||||||
|
sb.WriteString(sAddr[:t.DirNameLen])
|
||||||
sAddr = sAddr[t.DirNameLen:]
|
sAddr = sAddr[t.DirNameLen:]
|
||||||
}
|
}
|
||||||
|
|
||||||
dirs = append(dirs, sAddr)
|
sb.WriteRune(filepath.Separator)
|
||||||
|
sb.WriteString(sAddr)
|
||||||
return filepath.Join(dirs...)
|
return sb.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete removes the object with the specified address from the storage.
|
// Delete removes the object with the specified address from the storage.
|
||||||
|
|
Loading…
Reference in a new issue