summaryrefslogtreecommitdiffhomepage
path: root/src/mintage/parser.go
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2025-06-06 02:34:02 +0200
committerThomas Voss <mail@thomasvoss.com> 2025-06-06 02:34:02 +0200
commitdf75794b3f3ae6f5533b229c3b593e44fabec3fa (patch)
tree17d4428850f5ab91cc289271b51e589107949dfc /src/mintage/parser.go
parent82bb8f00a3507e09b2e9fb63586884b79c60ad95 (diff)
Try to be smarter about allocation?
Diffstat (limited to 'src/mintage/parser.go')
-rw-r--r--src/mintage/parser.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/mintage/parser.go b/src/mintage/parser.go
index 290f407..fe9ebd7 100644
--- a/src/mintage/parser.go
+++ b/src/mintage/parser.go
@@ -6,6 +6,7 @@ import (
"os"
"path/filepath"
"strconv"
+ "time"
)
func Parse(country string) ([3]Data, error) {
@@ -47,7 +48,7 @@ func Parse(country string) ([3]Data, error) {
}
func parseS(path string) ([]SRow, error) {
- rows := make([]SRow, 0, 69) /* TODO: Compute number of rows */
+ rows := make([]SRow, 0, guessRows(false))
f, err := os.Open(path)
if err != nil {
@@ -102,7 +103,7 @@ func parseS(path string) ([]SRow, error) {
}
func parseC(path string) ([]CRow, error) {
- rows := make([]CRow, 0, 69) /* TODO: Compute number of rows */
+ rows := make([]CRow, 0, guessRows(true))
f, err := os.Open(path)
if err != nil {
@@ -155,3 +156,13 @@ func parseC(path string) ([]CRow, error) {
return rows, nil
}
+
+func guessRows(commemorativep bool) int {
+ /* Try to guess the number of rows for Germany, because nobody needs more
+ rows than Germany. */
+ n := (time.Now().Year() - 2002) * 5
+ if commemorativep {
+ return n * 2
+ }
+ return n
+}