Currently, our frame index search algorithm time complexity for a GIF is O(N^2), we can burst it to O(N*logN), the time saving is distinct, for the example url like below, old algorithm needs 4.8ms, but new algorithm only need 0.038ms. Saving time for main thread.
// test code
for (int i = 0; i < animatedImage.frameCount; i++) {
[self frameIndexAtPlayHeadPosition:_durations[i]];
}
Old: 0.0048750638961791992 s
New: 0.000038027763366699219 s
Currently, our frame index search algorithm time complexity for a GIF is O(N^2), we can burst it to O(N*logN), the time saving is distinct, for the example url like below, old algorithm needs 4.8ms, but new algorithm only need 0.038ms. Saving time for main thread.
https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1562863518519&di=89f96479d2f9f85b01af61e281903af0&imgtype=0&src=http%3A%2F%2Fimg.mp.itc.cn%2Fupload%2F20170110%2Fb56b87be5f174eca81f9d06116aa1968.jpg