Skip to content

Commit aa87083

Browse files
authored
Replace defer with explicit Close() calls in export/import loops
1 parent 0e4c40f commit aa87083

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

benchmarks/cosmos-exim/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ func runExport(dbPath string) (int64, map[string][]*iavl.ExportNode, error) {
126126
if err != nil {
127127
return 0, nil, err
128128
}
129-
defer exporter.Close()
130129
for {
131130
node, err := exporter.Next()
132131
if errors.Is(err, iavl.ErrorExportDone) {
@@ -137,6 +136,7 @@ func runExport(dbPath string) (int64, map[string][]*iavl.ExportNode, error) {
137136
export = append(export, node)
138137
stats.AddNode(node)
139138
}
139+
exporter.Close()
140140
stats.AddDurationSince(start)
141141
fmt.Printf("%-13v: %v\n", name, stats.String())
142142
totalStats.Add(stats)
@@ -173,7 +173,6 @@ func runImport(version int64, exports map[string][]*iavl.ExportNode) error {
173173
if err != nil {
174174
return err
175175
}
176-
defer importer.Close()
177176
for _, node := range exports[name] {
178177
err = importer.Add(node)
179178
if err != nil {
@@ -185,6 +184,7 @@ func runImport(version int64, exports map[string][]*iavl.ExportNode) error {
185184
if err != nil {
186185
return err
187186
}
187+
importer.Close()
188188
stats.AddDurationSince(start)
189189
fmt.Printf("%-12v: %v\n", name, stats.String())
190190
totalStats.Add(stats)

0 commit comments

Comments
 (0)