File: cache_go19.go

package info (click to toggle)
golang-github-jszwec-csvutil 1.7.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 396 kB
  • sloc: makefile: 2
file content (18 lines) | stat: -rw-r--r-- 274 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// +build go1.9

package csvutil

import (
	"sync"
)

var fieldCache sync.Map // map[typeKey][]field

func cachedFields(k typeKey) fields {
	if v, ok := fieldCache.Load(k); ok {
		return v.(fields)
	}

	v, _ := fieldCache.LoadOrStore(k, buildFields(k))
	return v.(fields)
}