Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(text): Only compare cues when necessary
When a VTT cue spans a segment boundary, the cue will be duplicated across two segments. To avoid displaying duplicate cues, we compare the cues to be appended with the cues already in the list. 1. We can assume the cues to be appended at once have no duplicates. Make a copy of the current cues list, and compare the new cues only with the cues in the current cues list. If we append m new cues to a list of n cues, we can reduce the times to compare the cues from m*m*n/2 times to m*n times. 2. We compare the cues deeply by comparing their nested cues and all the elements. We can compare their start time, end time and payload first, and only compare their nested cues and all other elements when their start time, end time and payload are the same. If cue1 and cue2 both have m nested cues, we may not need to compare the nested cues instead of comparing m times. Fixes #3018 Change-Id: I9992f0e1834fd16e8aedaf1895b036bc7ca29190
- Loading branch information