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

Method resize

projects/JavaScript/proto/fbe.js:3004–3016  ·  view source on GitHub ↗

* Resize the map and get its first model * @this {!FieldModelMap} * @param {!number} size Size * @returns {[!FieldModel]} Base field model value

(size)

Source from the content-addressed store, hash-verified

3002 * @returns {[!FieldModel]} Base field model value
3003 */
3004 resize (size) {
3005 let fbeMapSize = size * (this._modelKey.fbeSize + this._modelValue.fbeSize)
3006 let fbeMapOffset = this._buffer.allocate(4 + fbeMapSize) - this._buffer.offset
3007 console.assert(((fbeMapOffset > 0) && ((this._buffer.offset + fbeMapOffset + 4) <= this._buffer.size)), 'Model is broken!')
3008
3009 this.writeUInt32(this.fbeOffset, fbeMapOffset)
3010 this.writeUInt32(fbeMapOffset, size)
3011 this.writeCount(fbeMapOffset + 4, 0, fbeMapSize)
3012
3013 this._modelKey.fbeOffset = fbeMapOffset + 4
3014 this._modelValue.fbeOffset = fbeMapOffset + 4 + this._modelKey.fbeSize
3015 return [this._modelKey, this._modelValue]
3016 }
3017
3018 /**
3019 * Check if the map is valid

Callers 1

setMethod · 0.95

Calls 3

writeCountMethod · 0.80
allocateMethod · 0.45
writeUInt32Method · 0.45

Tested by

no test coverage detected