Subscribe on changes!

The parent local variable defined by let is redundant

avatar
Dec 19th 2022

Vue version

v3.2.45

Link to minimal reproduction

https://github.com/vuejs/core/blob/main/packages/reactivity/src/effect.ts

Steps to reproduce

The parent local variable defined by let is redundant and is not used later. After being commented out and rewritten, it can still pass all test cases.

 run() {
    if (!this.active) {
      return this.fn()
    }
    // Delete a line of code
    let lastShouldTrack = shouldTrack
    // Delete part of the code
   
    try {
      this.parent = activeEffect
      activeEffect = this
      shouldTrack = true

      trackOpBit = 1 << ++effectTrackDepth

      if (effectTrackDepth <= maxMarkerBits) {
        initDepMarkers(this)
      } else {
        cleanupEffect(this)
      }
      return this.fn()
    } finally {
      if (effectTrackDepth <= maxMarkerBits) {
        finalizeDepMarkers(this)
      }

      trackOpBit = 1 << --effectTrackDepth

      activeEffect = this.parent
      shouldTrack = lastShouldTrack
      this.parent = undefined

      if (this.deferStop) {
        this.stop()
      }
    }
  }

What is expected?

The parent local variable defined by let is redundant and is not used later. After being commented out and rewritten, it can still pass all test cases.

What is actually happening?

The parent local variable defined by let is redundant and is not used later. After being commented out and rewritten, it can still pass all test cases.

System Info

Mac

Any additional comments?

No response

avatar
Dec 20th 2022

If you think this code can be optimized, please submit a PR, issues are for bug submission only.