UndoPrefixEnd is a partial inverse for roachpb.Key.PrefixEnd. In general, we can't undo PrefixEnd because it is lossy; we don't know how many FFs were stripped from the original key. For example: - key: 01 02 03 FF FF - PrefixEnd: 01 02 04 - UndoPrefixEnd: 01 02 03 Some keys are n
(b []byte)
| 2440 | // UndoPrefixEnd is implemented here to avoid a circular dependency on roachpb, |
| 2441 | // but arguably belongs in a byte-manipulation utility package. |
| 2442 | func UndoPrefixEnd(b []byte) (_ []byte, ok bool) { |
| 2443 | if len(b) == 0 || b[len(b)-1] == 0 { |
| 2444 | // Not a possible result of PrefixEnd. |
| 2445 | return nil, false |
| 2446 | } |
| 2447 | out := append([]byte(nil), b...) |
| 2448 | out[len(out)-1]-- |
| 2449 | return out, true |
| 2450 | } |
| 2451 | |
| 2452 | // MaxNonsortingVarintLen is the maximum length of an EncodeNonsortingVarint |
| 2453 | // encoded value. |
no outgoing calls
no test coverage detected
searching dependent graphs…