-
Notifications
You must be signed in to change notification settings - Fork 577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve codegen bundle size and typings #2999
base: main
Are you sure you want to change the base?
Conversation
2abd90e
to
ef8af3f
Compare
bebca0e
to
0bea135
Compare
0bea135
to
02ddb9a
Compare
02ddb9a
to
1a337a2
Compare
packages/api/src/client/util.ts
Outdated
: // $type === `${id}#${hash}` | ||
$type.length === id.length + 1 + hash.length && | ||
$type[id.length] === '#' && | ||
$type.startsWith(id) && | ||
$type.endsWith(hash)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For workloads where check$type()
is usually true
it's not clear to me that this is going to have the intended effect of a performance improvement over the simpler version. Or is the idea specifically to avoid allocating the additional string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did it mainly for the string allocation. The optimization in the false case is a bonus.
https://jsbench.me/l6m46vgr4q/1
true
case is 4% fasterfalse
case is > 50% faster
tested on FF
2714235
to
617d86c
Compare
6e398be
to
17b3081
Compare
This PR is the first of a 3 step changes aimed at improving typing in the atproto repo:
$type
property to records and user object typesNote
When reviewing, "codegen" commits can be ignored as they only contain generated code changes.