MCPcopy Create free account
hub / github.com/chronoxor/FastBinaryEncoding / resize

Method resize

projects/JavaScript/proto/fbe.js:2589–2600  ·  view source on GitHub ↗

* Resize the vector and get its first model * @this {!FieldModelVector} * @param {!number} size Size * @returns {!FieldModel} Base field model value

(size)

Source from the content-addressed store, hash-verified

2587 * @returns {!FieldModel} Base field model value
2588 */
2589 resize (size) {
2590 let fbeVectorSize = size * this._model.fbeSize
2591 let fbeVectorOffset = this._buffer.allocate(4 + fbeVectorSize) - this._buffer.offset
2592 console.assert(((fbeVectorOffset > 0) && ((this._buffer.offset + fbeVectorOffset + 4) <= this._buffer.size)), 'Model is broken!')
2593
2594 this.writeUInt32(this.fbeOffset, fbeVectorOffset)
2595 this.writeUInt32(fbeVectorOffset, size)
2596 this.writeCount(fbeVectorOffset + 4, 0, fbeVectorSize)
2597
2598 this._model.fbeOffset = fbeVectorOffset + 4
2599 return this._model
2600 }
2601
2602 /**
2603 * Check if the vector is valid

Callers 1

setMethod · 0.95

Calls 3

writeCountMethod · 0.80
allocateMethod · 0.45
writeUInt32Method · 0.45

Tested by

no test coverage detected