What's the Quickest Find in Array Method
I have a long list of parts. Each part has 2 different number formats—one numeric, one alphanumeric. Format A (12-234567) is the same part as Format B (ABCD-EFGH-IJKL). I have 2 arrays in a 1:1 correlation with each other, meaning arrayNumeric[1000] and arrayAlphaMumeric[1000] are the same part.
The script works as intended but both arrays have a length of about 70k. My issue is there is a 2-5 second lag as the script searches through the arrays. I have the "same" script written in php and apache computes it instantly, so I'm confused as to what the performance issue is.
I see there is no IndexOf unless you add it as a prototype, and the code i see to add indexOf is the same as what I wrote. I cannot seem to find a faster way to search through the large arrays. Here's the function I made to search them.
function getXref(num) {
for ( i = 0 ; i < arrayNumeric.length; i++) {
if ( arrayNumeric == num ) {
return arrayAlphaMumeric;
}
}
}
There seems to be a performance issue regardless of debug level, whether extendscript toolkit is closed or open, or if i write to console or not. So my question is basically what's the best way to handle finding values in large arrays?
