diff options
author | Max Kellermann <max@duempel.org> | 2016-02-19 19:40:23 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2016-02-19 19:40:23 +0100 |
commit | 2ef8403bfae6938067ddc36807d53e30c97373d5 (patch) | |
tree | 590e07315e52b2bc9e28c264cf83655ccac62efb /src/tag | |
parent | 1d3b2baee75e499e16bbf9733fe022d0f4396602 (diff) |
tag/Id3Load: don't read again if we already have enough data
Diffstat (limited to 'src/tag')
-rw-r--r-- | src/tag/Id3Load.cxx | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/tag/Id3Load.cxx b/src/tag/Id3Load.cxx index 7e41c12e1..c202ac619 100644 --- a/src/tag/Id3Load.cxx +++ b/src/tag/Id3Load.cxx @@ -72,6 +72,10 @@ tag_id3_read(FILE *stream, long offset, int whence) if (tag_size <= 0) return nullptr; /* Found a tag. Allocate a buffer and read it in. */ + if (size_t(tag_size) <= query_buffer_size) + /* we have enough data already */ + return UniqueId3Tag(id3_tag_parse(query_buffer, tag_size)); + std::unique_ptr<id3_byte_t[]> tag_buffer(new id3_byte_t[tag_size]); int tag_buffer_size = fill_buffer(tag_buffer.get(), tag_size, stream, offset, whence); |