skl/skl.go
func (s *Skiplist) findSpliceForLevel(key []byte, before *node, level int) (*node, *node) {
	for {
		// Assume before.key < key.
		next := s.getNext(before, level)
		if next == nil {
			return before, next
		}
		nextKey := next.key(s.arena)
		cmp := y.CompareKeys(key, nextKey)
		if cmp == 0 {
			// Equality case.
			return next, next
		}
		if cmp < 0 {
			// before.key < key < next.key. We are done for this level.
			return before, next
		}
		before = next // Keep moving right on this level.
	}
}
func (s *Skiplist) findSpliceForLevel(key []byte, before *node, level int) (*node, *node) {
	for {
		// Assume before.key < key.
		next := s.getNext(before, level)
		if next == nil {
			return before, next
		}
		nextKey := next.key(s.arena)
		cmp := y.CompareKeys(key, nextKey)
		if cmp == 0 {
			// Equality case.
			return next, next
		}
		if cmp < 0 {
			// before.key < key < next.key. We are done for this level.
			return before, next
		}
		before = next // Keep moving right on this level.
	}
}
func ( s * Skiplist ) findSpliceForLevel ( key [ ] byte , before * node , level int ) ( * node , * node ) { for { // Assume before.key < key. next := s . getNext ( before , level ) if next == nil { return before , next } nextKey := next . key ( s . arena ) cmp := y . CompareKeys ( key , nextKey ) if cmp == 0 { // Equality case. return next , next } if cmp < 0 { // before.key < key < next.key. We are done for this level. return before , next } before = next // Keep moving right on this level. } }
// findSpliceForLevel returns (outBefore, outAfter) with outBefore.key <= key <= outAfter.key.
// The input "before" tells us where to start looking.
// If we found a node with the same key, then we return outBefore = outAfter.
// Otherwise, outBefore.key < key < outAfter.key.
findSpliceForLevel returns ( outBefore outAfter ) with outBefore . key < = key < = outAfter . key . The input before tells us where to start looking . If we found a node with the same key then we return outBefore = outAfter . Otherwise outBefore . key < key < outAfter . key .