Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Increase the performance (x6) #474
Class to increase the performance of Mobile Detect lib.
Mobile Detect uses a loop with regular expressions to determine the device, and PHP is very slow on this. By reducing the size of the string in the regular expression we get increased performance.
The information theory says that the most frequent words provide less information. Then if it appears in 100% of cases the word "Mozilla" can exclude it from the regular expression as it will be irrelevant in determining the device in the User Agent.
What we do is create an array ($irrelevant) with the list of "irrelevant words" to exclude of User Agent.
I like the idea, I cannot add it to the current iteration (