mirror of
https://github.com/restic/restic.git
synced 2026-12-04 15:44:46 +00:00
Merge pull request #22236 from g4lb/perf/tree-node-marshal
data: call Node.MarshalJSON directly when building a tree
This commit is contained in:
2 files changed
+4
-2
No files matched your search
@@ -302,7 +302,9 @@ func (builder *TreeJSONBuilder) AddNode(node *Node) error {
|
||||
}
|
||||
builder.lastName = node.Name
|
||||
|
||||
val, err := json.Marshal(node)
|
||||
// Call MarshalJSON directly: json.Marshal would only validate and copy its
|
||||
// output, which is already compact.
|
||||
val, err := node.MarshalJSON()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -245,7 +245,7 @@ func BenchmarkBuildTree(b *testing.B) {
|
||||
nodes := make([]data.Node, size)
|
||||
for i := range nodes {
|
||||
// Archiver.SaveTree inputs in sorted order, so do that here too.
|
||||
nodes[i].Name = strconv.Itoa(i)
|
||||
nodes[i].Name = fmt.Sprintf("%03d", i)
|
||||
}
|
||||
|
||||
b.ResetTimer()
|
||||
|
||||
Reference in new issue
Block a user