I am looking to improve the efficiency of a custom column script regexp columns, by reducing the re calculation of expensive column calculations.
I want to only calculate each column once, and only for the columns displayed.
I have my columns set to be multi columns. I have 14 columns configured, but only two selected.
I have access to an array of all of the 14 columns configured for the script, so I can try calculate all the values at once, to reduce re-loading files. Not all columns will get a value for each file (as they regexp wont match), also they are not all selected and don't all need calculating.
The first time OnScriptColumn is called, scriptColData.columns.length has 14 items. Both selected columns are populated with values in this call.
The OnScriptColumn is called a second time where, scriptColData.columns.length has 7 items (I believe these are all the times that were not previously populated, the regexp not matching).
I have Improved the performance by removing any items from my column config list that are not in scriptColData.columns. This way any previously calculated columns wont get re calculated in subsequent calls. However If the second selected column didn't match an item it will be in scriptColData.columns for the second call and thus re run, possibly re opening the file.
For multicol Columns, why is the OnScriptColumn called multiple times? Esp if the target column (OnScriptColumn.col) already has a value?
Should scriptColData have all the possible columns for the script or just the ones that are selected? Could the scriptColData get a new prop selected columns?
For my use case, you might have a column configured to extracts data from a file name and from the file contents. If you only display the column that works on the file name, its still going to load the file. And if the second column does not get a value the first time OnScriptColumn the second time OnScriptColumn is called I will open the file a second time and still not get a value.
I have attached a copy of the script that has extra logging than the one in the main thread.
RegExpColumnsv 1.6.1.js.txt (36.5 KB)