Merge pull request #474 from steveyen/simplify-AddLocation
simplify TermLocationMap.AddLocation()
This commit is contained in:
commit
d026a44230
|
@ -47,15 +47,7 @@ type Locations []*Location
|
||||||
type TermLocationMap map[string]Locations
|
type TermLocationMap map[string]Locations
|
||||||
|
|
||||||
func (t TermLocationMap) AddLocation(term string, location *Location) {
|
func (t TermLocationMap) AddLocation(term string, location *Location) {
|
||||||
existingLocations, exists := t[term]
|
t[term] = append(t[term], location)
|
||||||
if exists {
|
|
||||||
existingLocations = append(existingLocations, location)
|
|
||||||
t[term] = existingLocations
|
|
||||||
} else {
|
|
||||||
locations := make(Locations, 1)
|
|
||||||
locations[0] = location
|
|
||||||
t[term] = locations
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type FieldTermLocationMap map[string]TermLocationMap
|
type FieldTermLocationMap map[string]TermLocationMap
|
||||||
|
|
Loading…
Reference in New Issue
Block a user