Removed unneccessary setting of length of arraybuffer #7

Closed
khankuan wants to merge 1 commits from fix-arraybuffer-set-length into master
khankuan commented 2015-06-17 11:32:35 +00:00 (Migrated from github.com)
No description provided.
SheetJSDev commented 2015-07-15 09:23:32 +00:00 (Migrated from github.com)

@khankuan The underlying buffer in the decode function is reused between calls to avoid numerous allocations of small buffers. That particular length assignment is important since it is used in the toString call to determine which bytes of the buffer are used in the encoding (the default behavior of the toString function uses the buffer's length field as the end index).

It might be preferable to explicitly specify the end in the function call itself, like mdb.toString('ucs2', 0, 2 * len);, but somewhere the length has to be specified

@khankuan The underlying buffer in the decode function is reused between calls to avoid numerous allocations of small buffers. That particular length assignment is important since it is used in the toString call to determine which bytes of the buffer are used in the encoding (the default behavior of the toString function uses the buffer's length field as the end index). It might be preferable to explicitly specify the end in the function call itself, like `mdb.toString('ucs2', 0, 2 * len);`, but somewhere the length has to be specified
khankuan commented 2015-07-15 15:56:24 +00:00 (Migrated from github.com)

Hmm ic. The problem occurred when I was in strict mode. It says that the buffer length is a read-only property (at least on chrome). When I removed that line, the library works as normal for my particular use case.

Hmm ic. The problem occurred when I was in strict mode. It says that the buffer length is a read-only property (at least on chrome). When I removed that line, the library works as normal for my particular use case.
SheetJSDev commented 2015-07-15 19:43:41 +00:00 (Migrated from github.com)

@khankuan do you have a small example? That particular line should not be triggered in Chrome because the Buffer is not generally available and the global check should prevent that logic from being called in the first place

@khankuan do you have a small example? That particular line should not be triggered in Chrome because the `Buffer` is not generally available and [the global check](https://github.com/khankuan/js-codepage/blob/efb228ab757f51fb3b3422d41deb718ee3de8aef/cputils.js#L36-L37) should prevent that logic from being called in the first place
SheetJSDev commented 2016-01-16 03:59:16 +00:00 (Migrated from github.com)

This should be fixed in version 1.4.0

This should be fixed in version 1.4.0

Pull request closed

Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/js-codepage#7
No description provided.