metadata: avoid allocations on delete
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
		| @@ -28,7 +28,13 @@ func (md Metadata) Set(key, val string) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func (md Metadata) Del(key string) { | func (md Metadata) Del(key string) { | ||||||
|  | 	// fast path | ||||||
|  | 	if _, ok := md[key]; ok { | ||||||
|  | 		delete(md, key) | ||||||
|  | 	} else { | ||||||
|  | 		// slow path | ||||||
| 		delete(md, textproto.CanonicalMIMEHeaderKey(key)) | 		delete(md, textproto.CanonicalMIMEHeaderKey(key)) | ||||||
|  | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| // Copy makes a copy of the metadata | // Copy makes a copy of the metadata | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user