Skip to content

Commit 57a2f7b

Browse files
authored
Update index.ts
1 parent 9fa3cbd commit 57a2f7b

1 file changed

Lines changed: 0 additions & 5 deletions

File tree

backend/src/embedding/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,9 @@ const hash = (v: string) => {
158158
const addFeat = (vec: Float32Array, dim: number, key: string, w: number) => {
159159
const h = hash(key);
160160
const value = w * (1 - ((h & 1) << 1));
161-
162-
// The core optimization: Check if dim is a power of two.
163-
// This check is extremely fast and allows V8's JIT to optimize heavily.
164161
if ((dim > 0) && (dim & (dim - 1)) === 0) {
165-
// FAST PATH: dim is a power of two. Use bitwise AND.
166162
vec[h & (dim - 1)] += value;
167163
} else {
168-
// SLOW PATH: Use modulo.
169164
vec[h % dim] += value;
170165
}
171166
}

0 commit comments

Comments
 (0)