lazy initialization of uuid string

pull/69/head
v2ray 2016-01-10 23:00:40 +01:00
parent 0107ea1636
commit 774095568f
1 changed files with 4 additions and 7 deletions

View File

@ -16,11 +16,10 @@ var (
type UUID struct { type UUID struct {
byteValue []byte byteValue []byte
stringValue string
} }
func (this *UUID) String() string { func (this *UUID) String() string {
return this.stringValue return bytesToString(this.byteValue)
} }
func (this *UUID) Bytes() []byte { func (this *UUID) Bytes() []byte {
@ -76,7 +75,6 @@ func ParseBytes(bytes []byte) (*UUID, error) {
} }
return &UUID{ return &UUID{
byteValue: bytes, byteValue: bytes,
stringValue: bytesToString(bytes),
}, nil }, nil
} }
@ -88,7 +86,6 @@ func ParseString(str string) (*UUID, error) {
uuid := &UUID{ uuid := &UUID{
byteValue: make([]byte, 16), byteValue: make([]byte, 16),
stringValue: str,
} }
b := uuid.byteValue[:] b := uuid.byteValue[:]