Skip to content

Commit 27b43e5

Browse files
committed
Post-merge, pre-publish
1 parent 9717c38 commit 27b43e5

File tree

8 files changed

+28
-113
lines changed

8 files changed

+28
-113
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "long",
3-
"version": "3.0.2",
3+
"version": "3.0.3",
44
"author": "Daniel Wirtz <dcode@dcode.io>",
55
"description": "A Long class for representing a 64 bit two's-complement integer value.",
66
"main": "dist/long.js",

dist/long.js

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,6 @@
131131
*/
132132
var UINT_CACHE = {};
133133

134-
/**
135-
* Determines if an integer value is cacheable.
136-
* @param {number} value Integer value
137-
* @param {boolean=} unsigned Whether unsigned or not
138-
* @returns {boolean}
139-
* @inner
140-
*/
141-
function cacheable(value, unsigned) {
142-
return unsigned ? 0 <= (value >>>= 0) && value < 256 : -128 <= (value |= 0) && value < 128;
143-
}
144-
145134
/**
146135
* @param {number} value
147136
* @param {boolean=} unsigned
@@ -151,7 +140,8 @@
151140
function fromInt(value, unsigned) {
152141
var obj, cachedObj, cache;
153142
if (unsigned) {
154-
if (cache = cacheable(value >>>= 0, true)) {
143+
value >>>= 0;
144+
if (cache = (0 <= value && value < 256)) {
155145
cachedObj = UINT_CACHE[value];
156146
if (cachedObj)
157147
return cachedObj;
@@ -161,7 +151,8 @@
161151
UINT_CACHE[value] = obj;
162152
return obj;
163153
} else {
164-
if (cache = cacheable(value |= 0, false)) {
154+
value |= 0;
155+
if (cache = (-128 <= value && value < 128)) {
165156
cachedObj = INT_CACHE[value];
166157
if (cachedObj)
167158
return cachedObj;

dist/long.min.js

Lines changed: 14 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/long.min.js.gz

-21 Bytes
Binary file not shown.

dist/long.min.map

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "long",
3-
"version": "3.0.2",
3+
"version": "3.0.3",
44
"author": "Daniel Wirtz <dcode@dcode.io>",
55
"description": "A Long class for representing a 64-bit two's-complement integer value.",
66
"main": "dist/long.js",

scripts/build.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ var rootDir = path.join(__dirname, ".."),
88
pkg = require(path.join(rootDir, "package.json")),
99
filename;
1010

11-
var scope = {
12-
DISPOSE: false
13-
};
11+
var scope = {};
1412

1513
// Build
1614
console.log("Building long.js with scope", JSON.stringify(scope, null, 2));

src/long.js

Lines changed: 4 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,6 @@ var INT_CACHE = {};
9797
*/
9898
var UINT_CACHE = {};
9999

100-
/**
101-
* Determines if an integer value is cacheable.
102-
* @param {number} value Integer value
103-
* @param {boolean=} unsigned Whether unsigned or not
104-
* @returns {boolean}
105-
* @inner
106-
*/
107-
function cacheable(value, unsigned) {
108-
return unsigned ? 0 <= (value >>>= 0) && value < 256 : -128 <= (value |= 0) && value < 128;
109-
}
110-
111100
/**
112101
* @param {number} value
113102
* @param {boolean=} unsigned
@@ -117,7 +106,8 @@ function cacheable(value, unsigned) {
117106
function fromInt(value, unsigned) {
118107
var obj, cachedObj, cache;
119108
if (unsigned) {
120-
if (cache = cacheable(value >>>= 0, true)) {
109+
value >>>= 0;
110+
if (cache = (0 <= value && value < 256)) {
121111
cachedObj = UINT_CACHE[value];
122112
if (cachedObj)
123113
return cachedObj;
@@ -127,7 +117,8 @@ function fromInt(value, unsigned) {
127117
UINT_CACHE[value] = obj;
128118
return obj;
129119
} else {
130-
if (cache = cacheable(value |= 0, false)) {
120+
value |= 0;
121+
if (cache = (-128 <= value && value < 128)) {
131122
cachedObj = INT_CACHE[value];
132123
if (cachedObj)
133124
return cachedObj;
@@ -192,15 +183,6 @@ Long.fromNumber = fromNumber;
192183
* @inner
193184
*/
194185
function fromBits(lowBits, highBits, unsigned) {
195-
//? if (DISPOSE) {
196-
if (disposed.length > 0) {
197-
var inst = disposed.shift();
198-
inst.low = lowBits | 0;
199-
inst.high = highBits | 0;
200-
inst.unsigned = !!unsigned;
201-
return inst;
202-
}
203-
//? }
204186
return new Long(lowBits, highBits, unsigned);
205187
}
206188

@@ -307,61 +289,6 @@ function fromValue(val) {
307289
* @expose
308290
*/
309291
Long.fromValue = fromValue;
310-
//? if (DISPOSE) {
311-
312-
// This is experimental code that will probably be removed in the future. At first glance something like this can seem
313-
// reasonable, but it would require a lot of additional (possibly MetaScript) code to perform disposal of intermediate
314-
// values everywhere. Otherwise, calling dispose as a user would not have much of an effect as any manually disposed
315-
// instances become reused a lot faster internally than a user can provide more. After testing this out for a bit I am
316-
// not convinced that the additional overhead from calling dispose() on literally every intermediate instance is worth
317-
// it.
318-
//
319-
// Alternatively, it has been suggested to add self-mutating methods in #24, but this would also be neglected by the
320-
// sheer number of intermediate instances that are still necessary.
321-
//
322-
// On this basis I'd recommend not to implement anything of this and leave memory optimization efforts to the VM.
323-
// -dcode
324-
325-
/**
326-
* Disposed Longs.
327-
* @type {!Array.<!Long>}
328-
* @inner
329-
*/
330-
var disposed = [];
331-
332-
/**
333-
* @param {!Long} inst
334-
* @returns {boolean}
335-
* @inner
336-
*/
337-
function dispose(inst) {
338-
if (disposed.length > 1023)
339-
return false;
340-
if (!(inst /* compatible */ instanceof Long))
341-
return false;
342-
// Do not dispose if cached
343-
if (inst.unsigned) {
344-
if (inst.high == 0 && UINT_CACHE[inst.low >>> 0] === inst)
345-
return false;
346-
} else {
347-
if ((inst.high == 0 || inst.high == -1) && INT_CACHE[inst.low] === inst)
348-
return false;
349-
}
350-
disposed.push(inst);
351-
return true;
352-
}
353-
354-
/**
355-
* Disposes a Long instance and queues it for reuse. If not ultimately necessary, it is recommended not to use this
356-
* method at all. If used however, it must be guaranteed that a disposed instance is never used again and that this
357-
* method is never called more than once with the same instance.
358-
* @function
359-
* @param {!Long} inst Long instance to dispose
360-
* @returns {boolean} Whether actually disposed
361-
* @expose
362-
*/
363-
Long.dispose = dispose;
364-
//? }
365292

366293
// NOTE: the compiler should inline these constant values below and then remove these variables, so there should be
367294
// no runtime penalty for these.

0 commit comments

Comments
 (0)