aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2016-11-21 19:41:22 -0500
committerGuillaume Horel <guillaume.horel@gmail.com>2016-11-21 19:41:22 -0500
commit8e75f331101efb49c2b10740afe0dcf4cfa8e0c7 (patch)
tree39f8151e62da89d3aa3fd3674e87be90a8a52bd7
parent236f65ac487731da53966da88a8b6fe2c4d7a625 (diff)
downloadlastfm-api-8e75f331101efb49c2b10740afe0dcf4cfa8e0c7.tar.gz
no need to sort
-rw-r--r--main.go21
1 files changed, 7 insertions, 14 deletions
diff --git a/main.go b/main.go
index 381de33..3c4a2d2 100644
--- a/main.go
+++ b/main.go
@@ -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
}