-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7334 from QwikDev/stuff
perf: don't bundle core in server or optimizer
- Loading branch information
Showing
42 changed files
with
339 additions
and
294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { assertTrue } from '../shared/error/assert'; | ||
|
||
export const mapApp_findIndx = <T>( | ||
elementVNode: (T | null)[], | ||
key: string, | ||
start: number | ||
): number => { | ||
assertTrue(start % 2 === 0, 'Expecting even number.'); | ||
let bottom = (start as number) >> 1; | ||
let top = (elementVNode.length - 2) >> 1; | ||
while (bottom <= top) { | ||
const mid = bottom + ((top - bottom) >> 1); | ||
const midKey = elementVNode[mid << 1] as string; | ||
if (midKey === key) { | ||
return mid << 1; | ||
} | ||
if (midKey < key) { | ||
bottom = mid + 1; | ||
} else { | ||
top = mid - 1; | ||
} | ||
} | ||
return (bottom << 1) ^ -1; | ||
}; | ||
|
||
export const mapArray_set = <T>( | ||
elementVNode: (T | null)[], | ||
key: string, | ||
value: T | null, | ||
start: number | ||
) => { | ||
const indx = mapApp_findIndx(elementVNode, key, start); | ||
if (indx >= 0) { | ||
if (value == null) { | ||
elementVNode.splice(indx, 2); | ||
} else { | ||
elementVNode[indx + 1] = value; | ||
} | ||
} else if (value != null) { | ||
elementVNode.splice(indx ^ -1, 0, key as any, value); | ||
} | ||
}; | ||
|
||
export const mapApp_remove = <T>( | ||
elementVNode: (T | null)[], | ||
key: string, | ||
start: number | ||
): T | null => { | ||
const indx = mapApp_findIndx(elementVNode, key, start); | ||
let value: T | null = null; | ||
if (indx >= 0) { | ||
value = elementVNode[indx + 1]; | ||
elementVNode.splice(indx, 2); | ||
return value; | ||
} | ||
return value; | ||
}; | ||
|
||
export const mapArray_get = <T>( | ||
elementVNode: (T | null)[], | ||
key: string, | ||
start: number | ||
): T | null => { | ||
const indx = mapApp_findIndx(elementVNode, key, start); | ||
if (indx >= 0) { | ||
return elementVNode[indx + 1] as T | null; | ||
} else { | ||
return null; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.