Skip to content

Commit d0691e0

Browse files
committed
Fix array length to 4Kb and optimize timer usage
1 parent 6d8791c commit d0691e0

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

JavaScript/3-poolify.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const poolify = (factory, size) => {
2222
// Usage
2323

2424
// Factory to allocate 4kb buffer
25-
const buffer = () => new Uint32Array(128);
25+
const buffer = () => new Uint32Array(1024);
2626

2727
// Allocate pool of 10 buffers
2828
const pool = poolify(buffer, 10);

JavaScript/4-improved.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const poolify = (factory, min, norm, max) => {
3030
// Usage
3131

3232
// Factory to allocate 4kb buffer
33-
const buffer = () => new Uint32Array(128);
33+
const buffer = () => new Uint32Array(1024);
3434

3535
// Allocate pool of 10 buffers
3636
const pool = poolify(buffer, 5, 10, 15);

JavaScript/5-async.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const poolify = (factory, min, norm, max) => {
4444
// Usage
4545

4646
// Factory to allocate 4kb buffer
47-
const buffer = () => new Uint32Array(128);
47+
const buffer = () => new Uint32Array(1024);
4848

4949
// Allocate pool of 10 buffers
5050
const pool = poolify(buffer, 3, 5, 7);
@@ -56,7 +56,7 @@ const next = () => {
5656
i++;
5757
if (i < 20) {
5858
setTimeout(next, i * 10);
59-
setTimeout(() => pool(item), i * 100);
59+
setTimeout(pool, i * 100, item);
6060
}
6161
});
6262
};

0 commit comments

Comments
 (0)