vendor/github.com/magiconair/properties/properties.go
changeset 265 05c40b36d3b2
parent 260 445e01aede7e
equal deleted inserted replaced
264:8f478162d991 265:05c40b36d3b2
     1 // Copyright 2018 Frank Schroeder. All rights reserved.
     1 // Copyright 2013-2022 Frank Schroeder. All rights reserved.
     2 // Use of this source code is governed by a BSD-style
     2 // Use of this source code is governed by a BSD-style
     3 // license that can be found in the LICENSE file.
     3 // license that can be found in the LICENSE file.
     4 
     4 
     5 package properties
     5 package properties
     6 
     6 
   698 	p.k = newKeys
   698 	p.k = newKeys
   699 }
   699 }
   700 
   700 
   701 // Merge merges properties, comments and keys from other *Properties into p
   701 // Merge merges properties, comments and keys from other *Properties into p
   702 func (p *Properties) Merge(other *Properties) {
   702 func (p *Properties) Merge(other *Properties) {
       
   703 	for _, k := range other.k {
       
   704 		if _, ok := p.m[k]; !ok {
       
   705 			p.k = append(p.k, k)
       
   706 		}
       
   707 	}
   703 	for k, v := range other.m {
   708 	for k, v := range other.m {
   704 		p.m[k] = v
   709 		p.m[k] = v
   705 	}
   710 	}
   706 	for k, v := range other.c {
   711 	for k, v := range other.c {
   707 		p.c[k] = v
   712 		p.c[k] = v
   708 	}
       
   709 
       
   710 outer:
       
   711 	for _, otherKey := range other.k {
       
   712 		for _, key := range p.k {
       
   713 			if otherKey == key {
       
   714 				continue outer
       
   715 			}
       
   716 		}
       
   717 		p.k = append(p.k, otherKey)
       
   718 	}
   713 	}
   719 }
   714 }
   720 
   715 
   721 // ----------------------------------------------------------------------------
   716 // ----------------------------------------------------------------------------
   722 
   717