diff options
| author | Guillaume Horel <guillaume.horel@gmail.com> | 2016-11-21 19:41:22 -0500 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@gmail.com> | 2016-11-21 19:41:22 -0500 |
| commit | 8e75f331101efb49c2b10740afe0dcf4cfa8e0c7 (patch) | |
| tree | 39f8151e62da89d3aa3fd3674e87be90a8a52bd7 /main.go | |
| parent | 236f65ac487731da53966da88a8b6fe2c4d7a625 (diff) | |
| download | lastfm-api-8e75f331101efb49c2b10740afe0dcf4cfa8e0c7.tar.gz | |
no need to sort
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 21 |
1 files changed, 7 insertions, 14 deletions
@@ -6,7 +6,6 @@ import ( "net/http" "net/http/httputil" "net/url" - "sort" "strconv" "time" ) @@ -103,21 +102,15 @@ func parseScrobbles(values url.Values, session *Session) []Scrobble { scrobbles := make([]Scrobble, 0, 1) parts := parseValues(values) keys := make([]int, len(parts)) - i := 0 - for key := range parts { - keys[i] = key - i++ - } - sort.Ints(keys) - for _, key := range keys { - scrobble, err := parsePart(parts[key]) - if err != nil { - continue + for i, c := 0, 0; i < 50 && c < len(parts); i++ { + if part, ok := parts[i]; ok { + c++ + if scrobble, err := parsePart(part); err != nil { + scrobble.Session = session.Key + scrobbles = append(scrobbles, scrobble) + } } - scrobble.Session = session.Key - scrobbles = append(scrobbles, scrobble) } - return scrobbles } |
