OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package memory | 5 package memory |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 "fmt" | 9 "fmt" |
10 "reflect" | 10 "reflect" |
11 "time" | 11 "time" |
12 | 12 |
13 "appengine/datastore" | 13 "appengine/datastore" |
14 | 14 |
15 » "github.com/luci/luci-go/common/funnybase" | 15 » "github.com/luci/luci-go/common/cmpbin" |
16 ) | 16 ) |
17 | 17 |
18 type kv struct{ k, v []byte } | 18 type kv struct{ k, v []byte } |
19 | 19 |
20 func indx(kind string, orders ...string) *qIndex { | 20 func indx(kind string, orders ...string) *qIndex { |
21 ancestor := false | 21 ancestor := false |
22 if kind[len(kind)-1] == '!' { | 22 if kind[len(kind)-1] == '!' { |
23 ancestor = true | 23 ancestor = true |
24 kind = kind[:len(kind)-1] | 24 kind = kind[:len(kind)-1] |
25 } | 25 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 // cat is a convenience method for concatenating anything with an underlying | 77 // cat is a convenience method for concatenating anything with an underlying |
78 // byte representation into a single []byte. | 78 // byte representation into a single []byte. |
79 func cat(bytethings ...interface{}) []byte { | 79 func cat(bytethings ...interface{}) []byte { |
80 buf := &bytes.Buffer{} | 80 buf := &bytes.Buffer{} |
81 for _, thing := range bytethings { | 81 for _, thing := range bytethings { |
82 switch x := thing.(type) { | 82 switch x := thing.(type) { |
83 case int, int64: | 83 case int, int64: |
84 » » » funnybase.Write(buf, reflect.ValueOf(x).Int()) | 84 » » » cmpbin.WriteInt(buf, reflect.ValueOf(x).Int()) |
85 case uint, uint64: | 85 case uint, uint64: |
86 » » » funnybase.WriteUint(buf, reflect.ValueOf(x).Uint()) | 86 » » » cmpbin.WriteUint(buf, reflect.ValueOf(x).Uint()) |
87 case float64: | 87 case float64: |
88 writeFloat64(buf, x) | 88 writeFloat64(buf, x) |
89 case byte, propValType: | 89 case byte, propValType: |
90 buf.WriteByte(byte(reflect.ValueOf(x).Uint())) | 90 buf.WriteByte(byte(reflect.ValueOf(x).Uint())) |
91 case []byte, serializedPval: | 91 case []byte, serializedPval: |
92 buf.Write(reflect.ValueOf(x).Convert(byteSliceType).Inte
rface().([]byte)) | 92 buf.Write(reflect.ValueOf(x).Convert(byteSliceType).Inte
rface().([]byte)) |
93 case string: | 93 case string: |
94 writeString(buf, x) | 94 writeString(buf, x) |
95 case time.Time: | 95 case time.Time: |
96 writeTime(buf, x) | 96 writeTime(buf, x) |
(...skipping 16 matching lines...) Expand all Loading... |
113 ret := cat(bytethings...) | 113 ret := cat(bytethings...) |
114 for i := range ret { | 114 for i := range ret { |
115 ret[i] ^= 0xFF | 115 ret[i] ^= 0xFF |
116 } | 116 } |
117 return ret | 117 return ret |
118 } | 118 } |
119 | 119 |
120 func sat(bytethings ...interface{}) string { | 120 func sat(bytethings ...interface{}) string { |
121 return string(cat(bytethings...)) | 121 return string(cat(bytethings...)) |
122 } | 122 } |
OLD | NEW |