MCPcopy Create free account
hub / github.com/dop251/goja / expand

Method expand

array_sparse.go:317–337  ·  view source on GitHub ↗
(idx uint32)

Source from the content-addressed store, hash-verified

315}
316
317func (a *sparseArrayObject) expand(idx uint32) bool {
318 if l := len(a.items); l >= 1024 {
319 if ii := a.items[l-1].idx; ii > idx {
320 idx = ii
321 }
322 if (bits.UintSize == 64 || idx < math.MaxInt32) && int(idx)>>3 < l {
323 //log.Println("Switching sparse->standard")
324 ar := &arrayObject{
325 baseObject: a.baseObject,
326 length: a.length,
327 propValueCount: a.propValueCount,
328 }
329 ar.setValuesFromSparse(a.items, int(idx))
330 ar.val.self = ar
331 ar.lengthProp.writable = a.lengthProp.writable
332 a._put("length", &ar.lengthProp)
333 return false
334 }
335 }
336 return true
337}
338
339func (a *sparseArrayObject) _defineIdxProperty(idx uint32, desc PropertyDescriptor, throw bool) bool {
340 var existing Value

Callers 2

_setOwnIdxMethod · 0.95
_defineIdxPropertyMethod · 0.95

Calls 2

setValuesFromSparseMethod · 0.95
_putMethod · 0.45

Tested by

no test coverage detected