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.
This commit is contained in:
wm4 2020-02-14 16:08:54 +01:00
parent c59ca06a0f
commit 5793cb40c8
1 changed files with 7 additions and 2 deletions

View File

@ -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);
}