mirror of https://github.com/v2ray/v2ray-core
lazy initialization of uuid string
parent
0107ea1636
commit
774095568f
|
@ -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[:]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue