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 {
byteValue []byte
stringValue string
}
func (this *UUID) String() string {
return this.stringValue
return bytesToString(this.byteValue)
}
func (this *UUID) Bytes() []byte {
@ -76,7 +75,6 @@ func ParseBytes(bytes []byte) (*UUID, error) {
}
return &UUID{
byteValue: bytes,
stringValue: bytesToString(bytes),
}, nil
}
@ -88,7 +86,6 @@ func ParseString(str string) (*UUID, error) {
uuid := &UUID{
byteValue: make([]byte, 16),
stringValue: str,
}
b := uuid.byteValue[:]