fixing whitespaces

This commit is contained in:
Jörg Breitbart
2017-07-16 13:44:00 +02:00
parent b965d0a0af
commit dd0fcb6320
2 changed files with 11 additions and 11 deletions
+5 -5
View File
@@ -156,7 +156,7 @@ const old_wcwidth = (function(opts) {
describe('wcwidth', () => {
it('same as old implementation for BMP and individual higher', () => {
for (let i=0; i<65536; ++i)
for (let i = 0; i < 65536; ++i)
assert.equal(wcwidth(i), old_wcwidth(i));
// test some individual higher to fullfill branching
assert.equal(wcwidth(0x10A01), old_wcwidth(0x10A01));
@@ -166,16 +166,16 @@ describe('wcwidth', () => {
it('new is at least 10 times faster', () => {
let start_new = new Date().getTime();
let x = 0;
for (let runs=0; runs<1; ++runs)
for (let runs = 0; runs < 1; ++runs)
for (let i=0; i<65536; ++i)
x = wcwidth(i);
let end_new = new Date().getTime();
let start_old = new Date().getTime();
let y = 0;
for (let runs=0; runs<1; ++runs)
for (let i=0; i<65536; ++i)
for (let runs = 0; runs < 1; ++runs)
for (let i = 0; i < 65536; ++i)
y = old_wcwidth(i);
let end_old = new Date().getTime();
assert.equal(((end_new-start_new)*10 < (end_old-start_old)), true);
assert.equal(((end_new-start_new) * 10 < (end_old-start_old)), true);
});
});
+6 -6
View File
@@ -1601,21 +1601,21 @@ export const wcwidth = (function(opts) {
return 1;
}
let table = new Uint8Array(16384);
for (let i=0; i<16384; ++i) {
for (let i = 0; i < 16384; ++i) {
let j = i * 4;
let num = 0;
num |= (wcwidthBMP(j+3));
num |= (wcwidthBMP(j + 3));
num <<= 2;
num |= (wcwidthBMP(j+2));
num |= (wcwidthBMP(j + 2));
num <<= 2;
num |= (wcwidthBMP(j+1));
num |= (wcwidthBMP(j + 1));
num <<= 2;
num |= (wcwidthBMP(j));
table[i] = num;
}
return function (num) {
num = num|0;
return (num<65536) ? (table[num>>2] >> ((num & 3) * 2))&3 : wcwidthHigh(num);
num = num | 0;
return (num < 65536) ? (table[num >> 2] >> ((num & 3) * 2)) & 3 : wcwidthHigh(num);
}
})({nul: 0, control: 0}); // configurable options