Repository: pixijs/pixijs
File: src/rendering/renderers/shared/buffer/Buffer.ts (TypeScript)

Code before:
    }

    /**
     * Sets the data in the buffer to the given value. This will immediately update the buffer on the GPU.
     * If you only want to update a subset of the buffer, you can pass in the size of the data.
     * @param value - the data to set
     * @param size - the size of the data in bytes
     * @param syncGPU - should the buffer be updated on the GPU immediately?
     */
    public setDataWithSize(value: TypedArray, size: number, syncGPU: boolean)
    {
        // Increment update ID
        this._updateID++;

        this._updateSize = (size * value.BYTES_PER_ELEMENT);

        // If the data hasn't changed, early return after emitting 'update'
        if (this._data === value)
        {
            if (syncGPU) this.emit('update', this);

            return;
        }

        // Cache old data and update to new value
        const oldData = this._data;

        this._data = value;
        this._dataInt32 = null;

        // Event handling
        if (!oldData || oldData.length !== value.length)
        {
            if (!this.shrinkToFit && oldData && value.byteLength < oldData.byteLength)
            {
                if (syncGPU) this.emit('update', this);
            }
            else
            {
                this.descriptor.size = value.byteLength;
                this._resourceId = uid('resource');
                this.emit('change', this);
            }

            return;
        }

        if (syncGPU) this.emit('update', this);
    }

    /**

Review comment (suggestion):
im not sure this should belong here as buffers tend not to deal with various views currently. This is quite specific need for one feature!

What about moving this view to the UniformGroup?

```uniformGroup.dataInt32``` <-- getter



Code after:
     * Sets the data in the buffer to the given value. This will immediately update the buffer on the GPU.
     * If you only want to update a subset of the buffer, you can pass in the size of the data.
     * @param value - the data to set
     * @param size - the size of the data in bytes
     * @param syncGPU - should the buffer be updated on the GPU immediately?
     */
    public setDataWithSize(value: TypedArray, size: number, syncGPU: boolean)
    {
        // Increment update ID
        this._updateID++;

        this._updateSize = (size * value.BYTES_PER_ELEMENT);

        // If the data hasn't changed, early return after emitting 'update'
        if (this._data === value)
        {
            if (syncGPU) this.emit('update', this);

            return;
        }

        // Cache old data and update to new value
        const oldData = this._data;

        this._data = value;
        this._dataInt32 = null;

        // Event handling
        if (!oldData || oldData.length !== value.length)
        {
            if (!this.shrinkToFit && oldData && value.byteLength < oldData.byteLength)
            {
                if (syncGPU) this.emit('update', this);
            }
            else
            {
                this.descriptor.size = value.byteLength;
                this._resourceId = uid('resource');
                this.emit('change', this);
            }

            return;
        }

        if (syncGPU) this.emit('update', this);
    }

    /**
     * updates the buffer on the GPU to reflect the data in the buffer.
     * By default it will update the entire buffer. If you only want to update a subset of the buffer,
     * you can pass in the size of the buffer to update.