Skip to content
This repository was archived by the owner on Feb 13, 2018. It is now read-only.

Commit 6404490

Browse files
committed
Constructor handles this initialization
1 parent ebb017e commit 6404490

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

statistics.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ type FileStatistics struct {
5959
var GlobalStatistics *Statistics = NewStatistics()
6060

6161
func NewStatistics() *Statistics {
62-
return &Statistics{}
62+
return &Statistics{
63+
files: make(map[string]*FileStatistics),
64+
}
6365
}
6466

6567
func (s *Statistics) SetFileStatus(filePath string, status string) {
@@ -93,16 +95,6 @@ func (s *Statistics) GetFileStatistics(filePath string) *FileStatistics {
9395
}
9496

9597
func (s *Statistics) ensureFileStatisticsCreated(filePath string) {
96-
// Fast check
97-
if s.files == nil {
98-
s.filesLock.Lock()
99-
// Check again in the critical region
100-
if s.files == nil {
101-
s.files = make(map[string]*FileStatistics)
102-
}
103-
s.filesLock.Unlock()
104-
}
105-
10698
// Fast check
10799
if _, ok := s.files[filePath]; !ok {
108100
s.filesLock.Lock()

0 commit comments

Comments
 (0)