Skip to content

Commit

Permalink
refactor select to spare one load
Browse files Browse the repository at this point in the history
  • Loading branch information
mnater committed Dec 6, 2023
1 parent 3af1137 commit cecf7df
Show file tree
Hide file tree
Showing 220 changed files with 518 additions and 666 deletions.
Binary file modified lang/af/af.wasm
Binary file not shown.
16 changes: 7 additions & 9 deletions lang/af/src/hyphenEngine.ts
Expand Up @@ -276,27 +276,25 @@ function select(ith: i32, startByte: i32, endByte: i32): i32 {
let posInByte: i32 = 0;
let pos: i32 = 0;
let firstPos: i32 = 0;

do {
while (run < 2) {
ith += run;
do {
while (count < ith) {
if (bytePos > endByte) {
return 0;
}
dWord = load<i64>(bytePos, 0, 8);
dWord0Count = 64 - <i32>popcnt<i64>(dWord);
count += dWord0Count;
bytePos += 8;
} while (count < ith);
count -= dWord0Count;
bytePos -= 8;
posInByte = get0PosInDWord(dWord, ith - count);
pos = ((bytePos - startByte) << 3) + posInByte;
}
posInByte = get0PosInDWord(dWord, ith - (count - dWord0Count));
pos = ((bytePos - 8 - startByte) << 3) + posInByte;
if (run === 0) {
firstPos = pos;
}
run += 1;
} while (run < 2);
}
return (firstPos << 8) + (pos - firstPos - 1);
}

Expand Down
Binary file modified lang/as/as.wasm
Binary file not shown.
16 changes: 7 additions & 9 deletions lang/as/src/hyphenEngine.ts
Expand Up @@ -276,27 +276,25 @@ function select(ith: i32, startByte: i32, endByte: i32): i32 {
let posInByte: i32 = 0;
let pos: i32 = 0;
let firstPos: i32 = 0;

do {
while (run < 2) {
ith += run;
do {
while (count < ith) {
if (bytePos > endByte) {
return 0;
}
dWord = load<i64>(bytePos, 0, 8);
dWord0Count = 64 - <i32>popcnt<i64>(dWord);
count += dWord0Count;
bytePos += 8;
} while (count < ith);
count -= dWord0Count;
bytePos -= 8;
posInByte = get0PosInDWord(dWord, ith - count);
pos = ((bytePos - startByte) << 3) + posInByte;
}
posInByte = get0PosInDWord(dWord, ith - (count - dWord0Count));
pos = ((bytePos - 8 - startByte) << 3) + posInByte;
if (run === 0) {
firstPos = pos;
}
run += 1;
} while (run < 2);
}
return (firstPos << 8) + (pos - firstPos - 1);
}

Expand Down
Binary file modified lang/be/be.wasm
Binary file not shown.
16 changes: 7 additions & 9 deletions lang/be/src/hyphenEngine.ts
Expand Up @@ -276,27 +276,25 @@ function select(ith: i32, startByte: i32, endByte: i32): i32 {
let posInByte: i32 = 0;
let pos: i32 = 0;
let firstPos: i32 = 0;

do {
while (run < 2) {
ith += run;
do {
while (count < ith) {
if (bytePos > endByte) {
return 0;
}
dWord = load<i64>(bytePos, 0, 8);
dWord0Count = 64 - <i32>popcnt<i64>(dWord);
count += dWord0Count;
bytePos += 8;
} while (count < ith);
count -= dWord0Count;
bytePos -= 8;
posInByte = get0PosInDWord(dWord, ith - count);
pos = ((bytePos - startByte) << 3) + posInByte;
}
posInByte = get0PosInDWord(dWord, ith - (count - dWord0Count));
pos = ((bytePos - 8 - startByte) << 3) + posInByte;
if (run === 0) {
firstPos = pos;
}
run += 1;
} while (run < 2);
}
return (firstPos << 8) + (pos - firstPos - 1);
}

Expand Down
Binary file modified lang/bg/bg.wasm
Binary file not shown.
16 changes: 7 additions & 9 deletions lang/bg/src/hyphenEngine.ts
Expand Up @@ -276,27 +276,25 @@ function select(ith: i32, startByte: i32, endByte: i32): i32 {
let posInByte: i32 = 0;
let pos: i32 = 0;
let firstPos: i32 = 0;

do {
while (run < 2) {
ith += run;
do {
while (count < ith) {
if (bytePos > endByte) {
return 0;
}
dWord = load<i64>(bytePos, 0, 8);
dWord0Count = 64 - <i32>popcnt<i64>(dWord);
count += dWord0Count;
bytePos += 8;
} while (count < ith);
count -= dWord0Count;
bytePos -= 8;
posInByte = get0PosInDWord(dWord, ith - count);
pos = ((bytePos - startByte) << 3) + posInByte;
}
posInByte = get0PosInDWord(dWord, ith - (count - dWord0Count));
pos = ((bytePos - 8 - startByte) << 3) + posInByte;
if (run === 0) {
firstPos = pos;
}
run += 1;
} while (run < 2);
}
return (firstPos << 8) + (pos - firstPos - 1);
}

Expand Down
Binary file modified lang/bn/bn.wasm
Binary file not shown.
16 changes: 7 additions & 9 deletions lang/bn/src/hyphenEngine.ts
Expand Up @@ -276,27 +276,25 @@ function select(ith: i32, startByte: i32, endByte: i32): i32 {
let posInByte: i32 = 0;
let pos: i32 = 0;
let firstPos: i32 = 0;

do {
while (run < 2) {
ith += run;
do {
while (count < ith) {
if (bytePos > endByte) {
return 0;
}
dWord = load<i64>(bytePos, 0, 8);
dWord0Count = 64 - <i32>popcnt<i64>(dWord);
count += dWord0Count;
bytePos += 8;
} while (count < ith);
count -= dWord0Count;
bytePos -= 8;
posInByte = get0PosInDWord(dWord, ith - count);
pos = ((bytePos - startByte) << 3) + posInByte;
}
posInByte = get0PosInDWord(dWord, ith - (count - dWord0Count));
pos = ((bytePos - 8 - startByte) << 3) + posInByte;
if (run === 0) {
firstPos = pos;
}
run += 1;
} while (run < 2);
}
return (firstPos << 8) + (pos - firstPos - 1);
}

Expand Down
Binary file modified lang/ca/ca.wasm
Binary file not shown.
16 changes: 7 additions & 9 deletions lang/ca/src/hyphenEngine.ts
Expand Up @@ -276,27 +276,25 @@ function select(ith: i32, startByte: i32, endByte: i32): i32 {
let posInByte: i32 = 0;
let pos: i32 = 0;
let firstPos: i32 = 0;

do {
while (run < 2) {
ith += run;
do {
while (count < ith) {
if (bytePos > endByte) {
return 0;
}
dWord = load<i64>(bytePos, 0, 8);
dWord0Count = 64 - <i32>popcnt<i64>(dWord);
count += dWord0Count;
bytePos += 8;
} while (count < ith);
count -= dWord0Count;
bytePos -= 8;
posInByte = get0PosInDWord(dWord, ith - count);
pos = ((bytePos - startByte) << 3) + posInByte;
}
posInByte = get0PosInDWord(dWord, ith - (count - dWord0Count));
pos = ((bytePos - 8 - startByte) << 3) + posInByte;
if (run === 0) {
firstPos = pos;
}
run += 1;
} while (run < 2);
}
return (firstPos << 8) + (pos - firstPos - 1);
}

Expand Down
Binary file modified lang/cs/cs.wasm
Binary file not shown.
16 changes: 7 additions & 9 deletions lang/cs/src/hyphenEngine.ts
Expand Up @@ -276,27 +276,25 @@ function select(ith: i32, startByte: i32, endByte: i32): i32 {
let posInByte: i32 = 0;
let pos: i32 = 0;
let firstPos: i32 = 0;

do {
while (run < 2) {
ith += run;
do {
while (count < ith) {
if (bytePos > endByte) {
return 0;
}
dWord = load<i64>(bytePos, 0, 8);
dWord0Count = 64 - <i32>popcnt<i64>(dWord);
count += dWord0Count;
bytePos += 8;
} while (count < ith);
count -= dWord0Count;
bytePos -= 8;
posInByte = get0PosInDWord(dWord, ith - count);
pos = ((bytePos - startByte) << 3) + posInByte;
}
posInByte = get0PosInDWord(dWord, ith - (count - dWord0Count));
pos = ((bytePos - 8 - startByte) << 3) + posInByte;
if (run === 0) {
firstPos = pos;
}
run += 1;
} while (run < 2);
}
return (firstPos << 8) + (pos - firstPos - 1);
}

Expand Down
Binary file modified lang/cy/cy.wasm
Binary file not shown.
16 changes: 7 additions & 9 deletions lang/cy/src/hyphenEngine.ts
Expand Up @@ -276,27 +276,25 @@ function select(ith: i32, startByte: i32, endByte: i32): i32 {
let posInByte: i32 = 0;
let pos: i32 = 0;
let firstPos: i32 = 0;

do {
while (run < 2) {
ith += run;
do {
while (count < ith) {
if (bytePos > endByte) {
return 0;
}
dWord = load<i64>(bytePos, 0, 8);
dWord0Count = 64 - <i32>popcnt<i64>(dWord);
count += dWord0Count;
bytePos += 8;
} while (count < ith);
count -= dWord0Count;
bytePos -= 8;
posInByte = get0PosInDWord(dWord, ith - count);
pos = ((bytePos - startByte) << 3) + posInByte;
}
posInByte = get0PosInDWord(dWord, ith - (count - dWord0Count));
pos = ((bytePos - 8 - startByte) << 3) + posInByte;
if (run === 0) {
firstPos = pos;
}
run += 1;
} while (run < 2);
}
return (firstPos << 8) + (pos - firstPos - 1);
}

Expand Down
Binary file modified lang/da/da.wasm
Binary file not shown.
16 changes: 7 additions & 9 deletions lang/da/src/hyphenEngine.ts
Expand Up @@ -276,27 +276,25 @@ function select(ith: i32, startByte: i32, endByte: i32): i32 {
let posInByte: i32 = 0;
let pos: i32 = 0;
let firstPos: i32 = 0;

do {
while (run < 2) {
ith += run;
do {
while (count < ith) {
if (bytePos > endByte) {
return 0;
}
dWord = load<i64>(bytePos, 0, 8);
dWord0Count = 64 - <i32>popcnt<i64>(dWord);
count += dWord0Count;
bytePos += 8;
} while (count < ith);
count -= dWord0Count;
bytePos -= 8;
posInByte = get0PosInDWord(dWord, ith - count);
pos = ((bytePos - startByte) << 3) + posInByte;
}
posInByte = get0PosInDWord(dWord, ith - (count - dWord0Count));
pos = ((bytePos - 8 - startByte) << 3) + posInByte;
if (run === 0) {
firstPos = pos;
}
run += 1;
} while (run < 2);
}
return (firstPos << 8) + (pos - firstPos - 1);
}

Expand Down
Binary file modified lang/de-x-syllable/de-x-syllable.wasm
Binary file not shown.
16 changes: 7 additions & 9 deletions lang/de-x-syllable/src/hyphenEngine.ts
Expand Up @@ -276,27 +276,25 @@ function select(ith: i32, startByte: i32, endByte: i32): i32 {
let posInByte: i32 = 0;
let pos: i32 = 0;
let firstPos: i32 = 0;

do {
while (run < 2) {
ith += run;
do {
while (count < ith) {
if (bytePos > endByte) {
return 0;
}
dWord = load<i64>(bytePos, 0, 8);
dWord0Count = 64 - <i32>popcnt<i64>(dWord);
count += dWord0Count;
bytePos += 8;
} while (count < ith);
count -= dWord0Count;
bytePos -= 8;
posInByte = get0PosInDWord(dWord, ith - count);
pos = ((bytePos - startByte) << 3) + posInByte;
}
posInByte = get0PosInDWord(dWord, ith - (count - dWord0Count));
pos = ((bytePos - 8 - startByte) << 3) + posInByte;
if (run === 0) {
firstPos = pos;
}
run += 1;
} while (run < 2);
}
return (firstPos << 8) + (pos - firstPos - 1);
}

Expand Down
Binary file modified lang/de/de.wasm
Binary file not shown.
16 changes: 7 additions & 9 deletions lang/de/src/hyphenEngine.ts
Expand Up @@ -276,27 +276,25 @@ function select(ith: i32, startByte: i32, endByte: i32): i32 {
let posInByte: i32 = 0;
let pos: i32 = 0;
let firstPos: i32 = 0;

do {
while (run < 2) {
ith += run;
do {
while (count < ith) {
if (bytePos > endByte) {
return 0;
}
dWord = load<i64>(bytePos, 0, 8);
dWord0Count = 64 - <i32>popcnt<i64>(dWord);
count += dWord0Count;
bytePos += 8;
} while (count < ith);
count -= dWord0Count;
bytePos -= 8;
posInByte = get0PosInDWord(dWord, ith - count);
pos = ((bytePos - startByte) << 3) + posInByte;
}
posInByte = get0PosInDWord(dWord, ith - (count - dWord0Count));
pos = ((bytePos - 8 - startByte) << 3) + posInByte;
if (run === 0) {
firstPos = pos;
}
run += 1;
} while (run < 2);
}
return (firstPos << 8) + (pos - firstPos - 1);
}

Expand Down
Binary file modified lang/el-monoton/el-monoton.wasm
Binary file not shown.

0 comments on commit cecf7df

Please sign in to comment.