mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-04 03:42:26 +00:00
Optimize feed engine normalization with array marking
- Introduced `NORMALIZED_ARRAY_MARKER` in `js/feedEngine/utils.js` to tag arrays that are already normalized. - Updated `normalizeItems` in `js/feedEngine/engine.js` to skip O(N) verification if the input array is marked. - Updated built-in stages and sorters to mark their output arrays using `markAsNormalized` when they safely construct new arrays from normalized inputs. - This avoids redundant O(N) scans after each stage, improving pipeline performance by ~10% end-to-end and eliminating overhead for trusted stages. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
f1c7c5755d
commit
f954bf3d89
5 files changed
+29
-12
No files matched your search
@@ -2,6 +2,15 @@
|
||||
|
||||
import { normalizeHashtag } from "../utils/hashtagNormalization.js";
|
||||
|
||||
export const NORMALIZED_ARRAY_MARKER = Symbol("FeedItemsNormalized");
|
||||
|
||||
export function markAsNormalized(items) {
|
||||
if (Array.isArray(items)) {
|
||||
items[NORMALIZED_ARRAY_MARKER] = true;
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
export function isPlainObject(value) {
|
||||
if (value === null || typeof value !== "object") {
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user