-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The original extension check uses strcasecmp to compare the strings one by one and byte by byte, which is very slow in ARM(and likely most RISC CPUs). Furthermore, in order to handle MIDI files, string comparisons are done twice for MIDI extensions. The new approach takes following advantages: 1. compare length first. 2. For some specific length, only compare with the extensions of the same length 3. since we know the length, we can compare word by word (int by int) rather than char by char. As we know the extension to match at compile-time, we can apply a mask of 0x20202020 to change the letter case. Please refer to code to see how this is handled. 4. After the comparison, we know it's MIDI or not. No need to compare to MIDI extensions twice. Unit test has been done to verify the new function. Test cases include all the valid extensions and some random other extensions. Signed-off-by: YumeYao <yumeyao@gmail.com>
- Loading branch information
Showing
1 changed file
with
98 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters