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
|
||||
|
||||
func (t TermLocationMap) AddLocation(term string, location *Location) {
|
||||
existingLocations, exists := t[term]
|
||||
if exists {
|
||||
existingLocations = append(existingLocations, location)
|
||||
t[term] = existingLocations
|
||||
} else {
|
||||
locations := make(Locations, 1)
|
||||
locations[0] = location
|
||||
t[term] = locations
|
||||
}
|
||||
t[term] = append(t[term], location)
|
||||
}
|
||||
|
||||
type FieldTermLocationMap map[string]TermLocationMap
|
||||
|
|
Loading…
Reference in New Issue
Block a user