Skip to content

Commit

Permalink
Update some code comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kriszyp committed Jan 2, 2021
1 parent 614fa85 commit 25709e5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
6 changes: 2 additions & 4 deletions pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,6 @@ class Packr extends Unpackr {
}
target[position++] = 0xcb
targetView.setFloat64(position, value)
/*if (!target[position[4] && !target[position[5] && !target[position[6] && !target[position[7] && !(target[0] & 0x78) < ) {
// something like this can be represented as a float with binary rounding
}*/
position += 8
}
} else if (type === 'object') {
Expand Down Expand Up @@ -389,6 +386,7 @@ class Packr extends Unpackr {
}

const writeObject = this.useRecords === false ? this.variableMapSize ? (object) => {
// this method is slightly slower, but generates "preferred serialization" (optimally small for smaller objects)
let keys = Object.keys(object)
let length = keys.length
if (length < 0x10) {
Expand All @@ -409,7 +407,7 @@ class Packr extends Unpackr {
}
} :
(object, safePrototype) => {
target[position++] = 0xde // always use map 16, so we can preallocate and set the length afterwards
target[position++] = 0xde // always using map 16, so we can preallocate and set the length afterwards
let objectOffset = position - start
position += 2
let size = 0
Expand Down
19 changes: 1 addition & 18 deletions unpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,24 +424,7 @@ function readStringJS(length) {

return result
}
/*function readShortString(length) {
let start = position
let end = start + length
while (position < end) {
const byte = src[position++];
if ((byte & 0x80) > 0) {
position = end
console.log('utf8 slice')
return src.utf8Slice(start, end)
}
}
if (srcStringEnd < end) {
srcStringStart = start
srcStringEnd = start + 8192
srcString = src.toString('latin1', start, srcStringEnd)
}
return srcString.slice(start - srcStringStart, end - srcStringStart)
}*/

function readArray(length) {
let array = new Array(length)
for (let i = 0; i < length; i++) {
Expand Down

0 comments on commit 25709e5

Please sign in to comment.