diff options
author | wm4 <wm4@nowhere> | 2020-02-14 16:08:54 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2020-02-14 16:08:54 +0100 |
commit | 5793cb40c83f6b56d33e539c5375d27977921f36 (patch) | |
tree | c1f6d742d79a602c4088a429032f6d56341a0b75 /stream | |
parent | c59ca06a0fff432ac4cae012bb0299a8db9a00d3 (diff) | |
download | mpv-5793cb40c83f6b56d33e539c5375d27977921f36.tar.bz2 mpv-5793cb40c83f6b56d33e539c5375d27977921f36.tar.xz |
stream: early-out in stream_seek_skip() if nothing is skipped
stream_seek() might somewhat show up in the profiler, even if it's a
no-OP, because of the MP_TRACE() call. I find this annoying. Otherwise,
this should be of no consequence, and should not break or improve
anything.
Diffstat (limited to 'stream')
-rw-r--r-- | stream/stream.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/stream/stream.c b/stream/stream.c index 157776cd87..a3285e4d8f 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -720,8 +720,13 @@ bool stream_seek(stream_t *s, int64_t pos) // it's a forward-seek. bool stream_seek_skip(stream_t *s, int64_t pos) { - return !s->seekable && pos > stream_tell(s) - ? stream_skip_read(s, pos - stream_tell(s)) + uint64_t cur_pos = stream_tell(s); + + if (cur_pos == pos) + return true; + + return !s->seekable && pos > cur_pos + ? stream_skip_read(s, pos - cur_pos) : stream_seek(s, pos); } |