Skip to content

Commit d4718a9

Browse files
committed
Use FindStringSubmatch instead of casting all the things
1 parent f126287 commit d4718a9

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

data/parser.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package data
1818

1919
import (
2020
"bufio"
21-
"bytes"
2221
"io"
2322
"io/ioutil"
2423
"log"
@@ -60,26 +59,26 @@ func ParseMap(pid string, entries EntryMap) {
6059
line, _, err := buff.ReadLine()
6160
// For each line
6261
for err == nil {
63-
raw := rowMatch.FindSubmatch(line)
62+
raw := rowMatch.FindStringSubmatch(string(line))
6463
// IF the line matches and isn't the root Device ID
65-
if raw != nil && !bytes.Equal(raw[5], []byte("00:00")) {
64+
if raw != nil && (raw[5] != "00:00") {
6665
// Generate Key <DeviceID>:<Inode>
67-
key := string(raw[5]) + ":" + string(raw[6])
66+
key := raw[5] + ":" + raw[6]
6867
// If key already exists
6968
if entry := entries[key]; entry != nil {
70-
if size := entry.Sizes[string(raw[3])]; size != nil {
69+
if size := entry.Sizes[raw[3]]; size != nil {
7170
size.Refs++
7271
entry.Weight += size.Size
7372
} else {
74-
entry.Increment(string(raw[1]), string(raw[2]), string(raw[3]))
73+
entry.Increment(raw[1], raw[2], raw[3])
7574
}
7675
} else {
7776
// Create new entry
7877
entry := &FileEntry{
79-
Name: string(raw[7]),
78+
Name: raw[7],
8079
Sizes: make(map[string]*SizeEntry),
8180
}
82-
entry.Increment(string(raw[1]), string(raw[2]), string(raw[3]))
81+
entry.Increment(raw[1], raw[2], raw[3])
8382
// Store new Entry
8483
entries[key] = entry
8584
}

0 commit comments

Comments
 (0)