From bdf50eda998c9248319793036038adbf2c37a4fd Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 16 Sep 2023 04:12:04 -0700 Subject: [PATCH] use some more auto (#1146) --- taglib/asf/asffile.cpp | 2 +- taglib/fileref.cpp | 5 ++--- taglib/mp4/mp4properties.cpp | 3 +-- taglib/mp4/mp4tag.cpp | 4 ++-- taglib/mpc/mpcproperties.cpp | 6 +++--- taglib/toolkit/tfile.cpp | 3 +-- 6 files changed, 10 insertions(+), 13 deletions(-) diff --git a/taglib/asf/asffile.cpp b/taglib/asf/asffile.cpp index 361389f2..7fcf46c1 100644 --- a/taglib/asf/asffile.cpp +++ b/taglib/asf/asffile.cpp @@ -641,7 +641,7 @@ void ASF::File::read() setValid(false); break; } - long size = static_cast(readQWORD(this, &ok)); + auto size = static_cast(readQWORD(this, &ok)); if(!ok) { setValid(false); break; diff --git a/taglib/fileref.cpp b/taglib/fileref.cpp index dad426d2..88ed3b98 100644 --- a/taglib/fileref.cpp +++ b/taglib/fileref.cpp @@ -230,8 +230,7 @@ namespace File* createInternal(FileName fileName, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle) { - File *file = detectByResolvers(fileName, readAudioProperties, audioPropertiesStyle); - if(file) + if(auto file = detectByResolvers(fileName, readAudioProperties, audioPropertiesStyle)) return file; #ifdef _WIN32 @@ -254,7 +253,7 @@ namespace return new Ogg::Vorbis::File(fileName, readAudioProperties, audioPropertiesStyle); if(ext == "OGA") { /* .oga can be any audio in the Ogg container. First try FLAC, then Vorbis. */ - File *file = new Ogg::FLAC::File(fileName, readAudioProperties, audioPropertiesStyle); + auto file = new Ogg::FLAC::File(fileName, readAudioProperties, audioPropertiesStyle); if(file->isValid()) return file; delete file; diff --git a/taglib/mp4/mp4properties.cpp b/taglib/mp4/mp4properties.cpp index 6aa80d2c..605f6cb4 100644 --- a/taglib/mp4/mp4properties.cpp +++ b/taglib/mp4/mp4properties.cpp @@ -239,8 +239,7 @@ MP4::Properties::read(File *file, Atoms *atoms) } } - MP4::Atom *drms = atom->find("drms"); - if(drms) { + if(atom->find("drms")) { d->encrypted = true; } } diff --git a/taglib/mp4/mp4tag.cpp b/taglib/mp4/mp4tag.cpp index 1cfbbacb..bec6b2ab 100644 --- a/taglib/mp4/mp4tag.cpp +++ b/taglib/mp4/mp4tag.cpp @@ -122,14 +122,14 @@ MP4::Tag::parseData2(const MP4::Atom *atom, int expectedFlags, bool freeForm) int i = 0; unsigned int pos = 0; while(pos < data.size()) { - const int length = static_cast(data.toUInt(pos)); + const auto length = static_cast(data.toUInt(pos)); if(length < 12) { debug("MP4: Too short atom"); return result; } const ByteVector name = data.mid(pos + 4, 4); - const int flags = static_cast(data.toUInt(pos + 8)); + const auto flags = static_cast(data.toUInt(pos + 8)); if(freeForm && i < 2) { if(i == 0 && name != "mean") { debug("MP4: Unexpected atom \"" + name + "\", expecting \"mean\""); diff --git a/taglib/mpc/mpcproperties.cpp b/taglib/mpc/mpcproperties.cpp index b90b24c4..9f865f6b 100644 --- a/taglib/mpc/mpcproperties.cpp +++ b/taglib/mpc/mpcproperties.cpp @@ -150,7 +150,7 @@ namespace tmp = b[0]; size = (size << 7) | (tmp & 0x7F); sizeLength++; - } while((tmp & 0x80)); + } while(tmp & 0x80); return size; } @@ -288,13 +288,13 @@ void MPC::Properties::readSV7(const ByteVector &data, offset_t streamLength) // convert gain info if(d->trackGain != 0) { - int tmp = static_cast((64.82 - static_cast(d->trackGain) / 100.) * 256. + .5); + auto tmp = static_cast((64.82 - static_cast(d->trackGain) / 100.) * 256. + .5); if(tmp >= (1 << 16) || tmp < 0) tmp = 0; d->trackGain = tmp; } if(d->albumGain != 0) { - int tmp = static_cast((64.82 - d->albumGain / 100.) * 256. + .5); + auto tmp = static_cast((64.82 - d->albumGain / 100.) * 256. + .5); if(tmp >= (1 << 16) || tmp < 0) tmp = 0; d->albumGain = tmp; } diff --git a/taglib/toolkit/tfile.cpp b/taglib/toolkit/tfile.cpp index 2cf13690..2ca4a1b2 100644 --- a/taglib/toolkit/tfile.cpp +++ b/taglib/toolkit/tfile.cpp @@ -124,7 +124,6 @@ offset_t File::find(const ByteVector &pattern, offset_t fromOffset, const ByteVe // The position in the file that the current buffer starts at. offset_t bufferOffset = fromOffset; - ByteVector buffer; // These variables are used to keep track of a partial match that happens at // the end of a buffer. @@ -159,7 +158,7 @@ offset_t File::find(const ByteVector &pattern, offset_t fromOffset, const ByteVe // then check for "before". The order is important because it gives priority // to "real" matches. - for(buffer = readBlock(bufferSize()); buffer.size() > 0; buffer = readBlock(bufferSize())) { + for(auto buffer = readBlock(bufferSize()); !buffer.isEmpty(); buffer = readBlock(bufferSize())) { // (1) previous partial match