forked from wmsmacdonald/vcdiff-decoder
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Motivation as in 9d8aeb8, and tested in the same way. I don’t know exactly _what_ about the non-class way of doing things made it not be tree-shakable; I can only speculate that it was the `.prototype.foo = ...` statements. The update to Babel is because the version we were using didn’t support class fields.
- Loading branch information
1 parent
9d8aeb8
commit 63584ed
Showing
7 changed files
with
1,244 additions
and
906 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
'use strict'; | ||
|
||
export default function NearCache(size) { | ||
this.size = size; | ||
this.near = new Array(this.size).fill(0); | ||
this.nextSlot = 0; | ||
} | ||
export default class NearCache { | ||
constructor(size) { | ||
this.size = size; | ||
this.near = new Array(this.size).fill(0); | ||
this.nextSlot = 0; | ||
} | ||
|
||
NearCache.prototype.update = function(address) { | ||
if (this.near.length > 0) { | ||
this.near[this.nextSlot] = address; | ||
this.nextSlot = (this.nextSlot + 1) % this.near.length; | ||
update(address) { | ||
if (this.near.length > 0) { | ||
this.near[this.nextSlot] = address; | ||
this.nextSlot = (this.nextSlot + 1) % this.near.length; | ||
} | ||
} | ||
}; | ||
|
||
NearCache.prototype.get = function(m, offset) { | ||
let address = this.near[m] + offset; | ||
return address; | ||
}; | ||
get(m, offset) { | ||
let address = this.near[m] + offset; | ||
return address; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
'use strict'; | ||
|
||
export default function SameCache(size) { | ||
this.size = size; | ||
this.same = new Array(this.size * 256).fill(0); | ||
} | ||
|
||
SameCache.prototype.update = function(address) { | ||
if (this.same.length > 0) { | ||
this.same[address % (this.size * 256)] = address; | ||
export default class SameCache { | ||
constructor(size) { | ||
this.size = size; | ||
this.same = new Array(this.size * 256).fill(0); | ||
} | ||
}; | ||
|
||
SameCache.prototype.get = function(m, offset) { | ||
let address = this.same[m * 256 + offset]; | ||
return address; | ||
}; | ||
update(address) { | ||
if (this.same.length > 0) { | ||
this.same[address % (this.size * 256)] = address; | ||
} | ||
}; | ||
|
||
get(m, offset) { | ||
let address = this.same[m * 256 + offset]; | ||
return address; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.