forcedotcom / sfdx-scanner

MIT License
214 stars 49 forks source link

FIX (GraphEngine): @W-15491246@: Implemented lazy path expansion. #1438

Closed jfeingold35 closed 5 months ago

jfeingold35 commented 5 months ago

This PR changes how ApexPathExpanders are processed. Previously, they were put into a stack and processed one at a time. The new system stacks the information from which the expanders are generated instead, and uses that information to generate them on-demand instead of preemptively. This reduces memory pressure and prevents certain code patterns from throwing LimitReached violations or OutOfMemory errors.

jfeingold35 commented 5 months ago

@stephen-carter-at-sf ,

  1. We need two different properties off of the exception, so the alternative to storing the exception would have been to create another object that holds those properties, which seemed like unnecessary clutter when I could just store the exception.
  2. The reason I went with a while loop instead of an iterator is because the act of processing the top of the stack can cause more items to get added to the top, and also we're iterating over two stacks in tandem. Trying to handle that with an iterator seemed like more trouble than it was worth.