ast: Rename UUID symbol to avoid confusion

Also remove the prefix on the cache key since it's not needed (the
type alias is enough to prevent conflicts, e.g., uuidCachingKey("X")
!= "X".)

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
This commit is contained in:
Torin Sandall
2020-04-21 08:46:09 -04:00
parent bbcbbe175a
commit caa4072279
2 changed files with 7 additions and 9 deletions
+4 -4
View File
@@ -211,8 +211,8 @@ var DefaultBuiltins = [...]*Builtin{
// Units
UnitsParseBytes,
// Uuid
UUID,
// UUIDs
UUIDRFC4122,
}
// BuiltinMap provides a convenient mapping of built-in names to
@@ -990,8 +990,8 @@ var UnitsParseBytes = &Builtin{
* Type
*/
// UUID returns a version 4 uuid string
var UUID = &Builtin{
// UUIDRFC4122 returns a version 4 UUID string.
var UUIDRFC4122 = &Builtin{
Name: "uuid.rfc4122",
Decl: types.NewFunction(
types.Args(types.S),
+3 -5
View File
@@ -13,11 +13,9 @@ import (
type uuidCachingKey string
func builtinUUID(bctx BuiltinContext, args []*ast.Term, iter func(*ast.Term) error) error {
var cachingKey = uuidCachingKey("UUID-" + args[0].Value.String())
func builtinUUIDRFC4122(bctx BuiltinContext, args []*ast.Term, iter func(*ast.Term) error) error {
var cachingKey = uuidCachingKey(args[0].Value.String())
id, ok := bctx.Cache.Get(cachingKey)
var uuidv4 *ast.Term
if !ok {
@@ -39,5 +37,5 @@ func builtinUUID(bctx BuiltinContext, args []*ast.Term, iter func(*ast.Term) err
}
func init() {
RegisterBuiltinFunc(ast.UUID.Name, builtinUUID)
RegisterBuiltinFunc(ast.UUIDRFC4122.Name, builtinUUIDRFC4122)
}