- Removed NSLog in NBPhoneNumberParsingPerfTest
- Converted isNan from a method to a function.
- isNan is now only checking for integer value instead of a float, as the intended use for the function is to remove non-geological calling code, which can only be an integer.
Improve phone number parsing performance by:
- Using NSCache to cache metadata, so when parsing phone numbers from different regions, the metadata cache is still going to be valid.
- Improve various methods in NBPhoneNumberUtil by removing redundant operations, or using a different construct that’s more performant (such as using NSCharacterSet instead of NSScanner to check if a string is a number).
Also added a performance test that reads sample phone numbers from the metadata, and parse them.
Performance improvement result:
Machine:
Mac Pro (Late 2013)
2.7 GHz. 12-Core Intel Xeon E5
64 GB 1866 MHz DDR3
macOS High Sierra 10.13.3
Phone number to parse count: 2688
Baseline (5 runs -- in seconds):
0.362
0.372
0.385
0.363
0.365
After Change (5 runs -- in seconds):
0.312 (14% faster)
0.315 (13% faster)
0.317 (12% faster)
0.327 (10% faster)
0.308 (15% faster)
Improve phone number parsing performance by:
- Using NSCache to cache metadata, so when parsing phone numbers from different regions, the metadata cache is still going to be valid.
- Improve various methods in NBPhoneNumberUtil by removing redundant operations, or using a different construct that’s more performant (such as using NSCharacterSet instead of NSScanner to check if a string is a number).
Also added a performance test that reads sample phone numbers from the metadata, and parse them.
Performance improvement result:
Machine:
Mac Pro (Late 2013)
2.7 GHz. 12-Core Intel Xeon E5
64 GB 1866 MHz DDR3
macOS High Sierra 10.13.3
Phone number to parse count: 2688
Baseline (5 runs -- in seconds):
0.362
0.372
0.385
0.363
0.365
After Change (5 runs -- in seconds):
Serial Parsing:
0.312 (14% faster)
0.315 (13% faster)
0.317 (12% faster)
0.327 (10% faster)
0.317 (12% faster)
- Add NSError ** parameter to -[NBRegularExpressionCache regularExpressionForPattern:error] method.
- Consolidating the expansion of gzipped data into one method.
I believe that the coding and copy methods in these classes are unused.
I have disabled them behind an #ifdef flag.
If no one files any bugs, we can remove them.
There is no reason to have an @synchronized here. An NSArray by itself is
immutable so it is thread safe. An NSMutableArray by definition is not thread
safe if it is being accessed/mutated on multiple threads.
Other small enhancements to reduce number of calls being made.