Skip to content

Commit

Permalink
increasing buffer to file size
Browse files Browse the repository at this point in the history
  • Loading branch information
Mzack9999 committed May 10, 2024
1 parent 8eb548f commit 1b5e022
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,14 @@ func DedupeLines(filename string) error {
seenLines := make(map[string]struct{})
var deduplicatedLines []string

info, err := file.Stat()
if err != nil {
return err
}
scanner := bufio.NewScanner(file)
maxSize := int(info.Size())
buffer := make([]byte, 0, maxSize)
scanner.Buffer(buffer, maxSize)
for scanner.Scan() {
line := scanner.Text()
if _, exists := seenLines[line]; !exists {
Expand Down

0 comments on commit 1b5e022

Please sign in to comment.