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

Method resize

projects/JavaScript/proto/fbe.js:2793–2804  ·  view source on GitHub ↗

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

(size)

Source from the content-addressed store, hash-verified

2791 * @returns {!FieldModel} Base field model value
2792 */
2793 resize (size) {
2794 let fbeSetSize = size * this._model.fbeSize
2795 let fbeSetOffset = this._buffer.allocate(4 + fbeSetSize) - this._buffer.offset
2796 console.assert(((fbeSetOffset > 0) && ((this._buffer.offset + fbeSetOffset + 4) <= this._buffer.size)), 'Model is broken!')
2797
2798 this.writeUInt32(this.fbeOffset, fbeSetOffset)
2799 this.writeUInt32(fbeSetOffset, size)
2800 this.writeCount(fbeSetOffset + 4, 0, fbeSetSize)
2801
2802 this._model.fbeOffset = fbeSetOffset + 4
2803 return this._model
2804 }
2805
2806 /**
2807 * Check if the set value is valid

Callers 1

setMethod · 0.95

Calls 3

writeCountMethod · 0.80
allocateMethod · 0.45
writeUInt32Method · 0.45

Tested by

no test coverage detected