-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
refactor(compiler-vapor): generate unique variable to prevent collisions with user variables #13822
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
base: minor
Are you sure you want to change the base?
Conversation
…ollisions with user variables
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/compiler-vapor
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/runtime-vapor
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
❌ Deploy Preview for vue-sfc-playground failed. Why did it fail? →
|
91aeda6
to
9adfd60
Compare
genVarName(prefix: string, baseNum: number): string { | ||
let num = baseNum | ||
let name = `${prefix}${num}` | ||
while (this.bindingNames.has(name) || this.seenVarNames.has(name)) { |
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.
A small optimization could be to analyze the bindingMetadata
in the constructor ahead of time and create a mapping for what the next free name/number is; i.e. if bindingMetadata
has t0
, t1
, t2
, and t4
then this mapping could be built like { 0 => 3, 1 => 3, 2 => 3, 4 => 5 }
and it can be looked up for constant-time instead of potentially linear time complexity; likewise for the increaseId
function
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.
see 7eb3192
Please feel free to review.
…son/refactor/compiler-vapor-codegen
this PR includes #13821