Twintop's Resource Bar

Twintop's Resource Bar

670k Downloads

Bar text logic: refactor scanning

Twintop opened this issue ยท 0 comments

commented

Scanning for logic symbols is occurring more often than it should be (in theory).

Presently the scan is run every time RemoveInvalidVariablesFromBarText() is entered plus an additional time for every logic test in that input string. Additionally, if there are any nested logic tests these all get called again (albeit on a subset) for further logic processing.

This is not only wasting CPU but also bloating out memory usage for every frame that the bar text needs to be processed.

Two phased approach to streamlining this:

  • 1. Remove the "logicScan" variable and instead use the existing/main scan done upon entry in to RemoveInvalidVariablesFromBarText() to provide this data. This will reduce both CPU usage and memory by not duplicating data.
  • 2a. Pass the original "scan" results in to RemoveInvalidVariablesFromBarText() when making recursive calls. This will reduce the CPU usage required but likely won't decrease memory usage much due to a larger block of data being passed by value.
  • 2b. Additional change to 2a above: Decompose the overall function in to a parent function and inline sub functions that can share the variable scope of the parent to prevent passing data by value around and instead use the same parent 'scan' table. Could this be achieved by passive relevant upper/lower bounds on the 'scan' table data records to use? Could be much lower memory usage and the same CPU usage improvement as above.