MCPcopy Create free account
hub / github.com/google/gapid / adjust

Function adjust

core/math/interval/algorithm.go:151–170  ·  view source on GitHub ↗

adjust implements list size adjustment logic, given a delta in size, and an index to adjust at

(l MutableList, at, delta int)

Source from the content-addressed store, hash-verified

149// adjust implements list size adjustment logic, given a delta in size, and an
150// index to adjust at
151func adjust(l MutableList, at, delta int) {
152 if delta == 0 {
153 return
154 }
155 oldLen := l.Length()
156 newLen := oldLen + delta
157 if delta > 0 {
158 l.Resize(newLen)
159 }
160 copyStart := at - delta
161 copyTo := at
162 if copyStart < 0 {
163 copyTo -= copyStart
164 copyStart = 0
165 }
166 l.Copy(copyTo, copyStart, newLen-copyTo)
167 if delta < 0 {
168 l.Resize(newLen)
169 }
170}

Callers 2

mergeFunction · 0.85
cutFunction · 0.85

Calls 3

LengthMethod · 0.65
ResizeMethod · 0.65
CopyMethod · 0.65

Tested by

no test coverage detected