encodeBit two uint32 numbers by bit. First 32 bits store k1 and last 32 bits store k2.
(k1, k2 int)
| 2514 | // encodeBit two uint32 numbers by bit. |
| 2515 | // First 32 bits store k1 and last 32 bits store k2. |
| 2516 | func encodeIndex(k1, k2 int) uint64 { |
| 2517 | safeToConvert := func(num int) { |
| 2518 | if num > math.MaxUint32 { |
| 2519 | panic("unsafe conversion: integer value is too large for uint32") |
| 2520 | } |
| 2521 | } |
| 2522 | safeToConvert(k1) |
| 2523 | safeToConvert(k2) |
| 2524 | return uint64(uint32(k1))<<32 | uint64(uint32(k2)) |
| 2525 | } |
| 2526 | |
| 2527 | func decodeIndex(pair uint64) (uint32, uint32) { |
| 2528 | k1 := uint32(pair >> 32) |
no outgoing calls