Commit 027a84b
authored
filebeat/filestream: Use gzip.Reader.Reset instead of Close+NewReader (#48516)
Replace the pattern of closing the gzip reader and creating a new one with a call to gzip.Reader.Reset() in gzipSeekerReader.Seek().
`Reset()` is the idiomatic way to reuse a gzip reader when switching to a new underlying reader. It:
- Reuses internal buffers instead of allocating new ones, reducing memory pressure and GC overhead
- Is semantically equivalent to creating a new reader (discards current state and reinitializes)
- Eliminates the unnecessary `Close()` call whose error was being ignored anyway1 parent 7eccae0 commit 027a84b
1 file changed
+2
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
| 160 | + | |
164 | 161 | | |
165 | 162 | | |
166 | | - | |
| 163 | + | |
167 | 164 | | |
168 | 165 | | |
169 | 166 | | |
| |||
0 commit comments