BytesNext returns the next possible byte slice, using the extra capacity of the provided slice if possible, and if not, appending an \x00.
(b []byte)
| 1139 | // BytesNext returns the next possible byte slice, using the extra capacity |
| 1140 | // of the provided slice if possible, and if not, appending an \x00. |
| 1141 | func BytesNext(b []byte) []byte { |
| 1142 | if cap(b) > len(b) { |
| 1143 | bNext := b[:len(b)+1] |
| 1144 | if bNext[len(bNext)-1] == 0 { |
| 1145 | return bNext |
| 1146 | } |
| 1147 | } |
| 1148 | // TODO(spencer): Do we need to enforce KeyMaxLength here? |
| 1149 | // Switched to "make and copy" pattern in #4963 for performance. |
| 1150 | bn := make([]byte, len(b)+1) |
| 1151 | copy(bn, b) |
| 1152 | bn[len(bn)-1] = 0 |
| 1153 | return bn |
| 1154 | } |
| 1155 | |
| 1156 | func bytesPrefixEnd(b []byte) []byte { |
| 1157 | // Switched to "make and copy" pattern in #4963 for performance. |
no outgoing calls
no test coverage detected
searching dependent graphs…