weechat-protocol.js: use pointer instead of slicing
I don't know if this changes anything to performance, but my instinct tells me that it's better to update a pointer within a big array to get slices than creating a new slice each time. Perhaps the JS engine is clever enough to not create a copy each time and only update its internal references of the array bounds, but just in case...
This commit is contained in:
parent
c12f56c614
commit
df7d21f63f
|
@ -102,9 +102,9 @@ WeeChatProtocol.prototype = {
|
|||
return "";
|
||||
},
|
||||
_getSlice: function(length) {
|
||||
var slice = this.data.slice(0, length);
|
||||
var slice = this._data.slice(this._dataAt, this._dataAt + length);
|
||||
|
||||
this.data = this.data.slice(length);
|
||||
this._dataAt += length;
|
||||
|
||||
return slice;
|
||||
},
|
||||
|
@ -148,11 +148,13 @@ WeeChatProtocol.prototype = {
|
|||
return values;
|
||||
},
|
||||
_setData: function (data) {
|
||||
this.data = data;
|
||||
this._data = data;
|
||||
},
|
||||
parse: function(data) {
|
||||
var self = this;
|
||||
|
||||
this._setData(data);
|
||||
this._dataAt = 0;
|
||||
|
||||
var header = this._getHeader();
|
||||
var id = this._getId();
|
||||
|
|
Loading…
Reference in New Issue