mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-03 20:21:44 +00:00
pkg/stringid: precompile regexp
Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
This commit is contained in:
@@ -10,9 +10,11 @@ import (
|
||||
|
||||
const shortLen = 12
|
||||
|
||||
var validShortID = regexp.MustCompile("^[a-z0-9]{12}$")
|
||||
|
||||
// Determine if an arbitrary string *looks like* a short ID.
|
||||
func IsShortID(id string) bool {
|
||||
return regexp.MustCompile("^[a-z0-9]{12}$").MatchString(id)
|
||||
return validShortID.MatchString(id)
|
||||
}
|
||||
|
||||
// TruncateID returns a shorthand version of a string identifier for convenience.
|
||||
|
||||
Reference in New Issue
Block a user