When starting development I used the contains method of the array which worked great without any performance issues. I later needed to allow searching with wildcards, this however introduces a performance issue in the events since I was forced to iterate over the array because the array contains method does not accept wildcards. I've tried the for each method of the arrays and also a simple while loop using regex for both methods to find a match with no success. By no success, I mean without the noticeable performance hit that I get (all animation stops) while the loop completes.
You'll just have to loop through and compare each value. How big is the array? And what kind of searches do you need to make?
Develop games in your browser. Powerful, performant & highly capable.
The array is 1D but has about 50K elements that are going to grow. I need to make wildcard searches for any text in the element. The only other thing I can think of is breaking the array up into categories with a dictionary but this is a huge pain. I guess I will have to do it and hope for some improvements.
What a huge difference between using contains and a loop.
Do you just need to check if the value is in the array (like contains does)? What about doing a regex search on Array.AsJSON?
Never thought about searching through the json file. I will attempt trying this method first if not successful then I wil break the array into the dictionary. Hopefully I have some success with one of these methods and will update thread as soon as i do.
I had great success with searching through a loaded file. I'm going to stop researching the problem and consider the issue solved. If anyone is curious of what worked:
(1) load entire json file into a global variable(data) at layout start
(2) added delimiters to start and end of searchable text
(3) query the data using "test regex" condition
*** after using this method the animation stop until search completed no longer happens (or at least not noticeable on my test devices) ***