Browse code

image: precompile regexp

Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>

unclejack authored on 2015/05/14 03:42:45
Showing 1 changed files
... ...
@@ -19,6 +19,8 @@ import (
19 19
 // For more information see: http://sourceforge.net/p/aufs/aufs3-standalone/ci/aufs3.12/tree/config.mk
20 20
 const MaxImageDepth = 127
21 21
 
22
+var validHex = regexp.MustCompile(`^([a-f0-9]{64})$`)
23
+
22 24
 type Image struct {
23 25
 	ID              string            `json:"id"`
24 26
 	Parent          string            `json:"parent,omitempty"`
... ...
@@ -266,7 +268,6 @@ func NewImgJSON(src []byte) (*Image, error) {
266 266
 
267 267
 // Check wheather id is a valid image ID or not
268 268
 func ValidateID(id string) error {
269
-	validHex := regexp.MustCompile(`^([a-f0-9]{64})$`)
270 269
 	if ok := validHex.MatchString(id); !ok {
271 270
 		return fmt.Errorf("image ID '%s' is invalid", id)
272 271
 	}