use some more auto (#1146)

This commit is contained in:
Rosen Penev 2023-09-16 04:12:04 -07:00 committed by GitHub
parent 653c2fe9e1
commit bdf50eda99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 13 deletions

View File

@ -641,7 +641,7 @@ void ASF::File::read()
setValid(false);
break;
}
long size = static_cast<long>(readQWORD(this, &ok));
auto size = static_cast<long>(readQWORD(this, &ok));
if(!ok) {
setValid(false);
break;

View File

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

View File

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

View File

@ -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<int>(data.toUInt(pos));
const auto length = static_cast<int>(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<int>(data.toUInt(pos + 8));
const auto flags = static_cast<int>(data.toUInt(pos + 8));
if(freeForm && i < 2) {
if(i == 0 && name != "mean") {
debug("MP4: Unexpected atom \"" + name + "\", expecting \"mean\"");

View File

@ -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<int>((64.82 - static_cast<short>(d->trackGain) / 100.) * 256. + .5);
auto tmp = static_cast<int>((64.82 - static_cast<short>(d->trackGain) / 100.) * 256. + .5);
if(tmp >= (1 << 16) || tmp < 0) tmp = 0;
d->trackGain = tmp;
}
if(d->albumGain != 0) {
int tmp = static_cast<int>((64.82 - d->albumGain / 100.) * 256. + .5);
auto tmp = static_cast<int>((64.82 - d->albumGain / 100.) * 256. + .5);
if(tmp >= (1 << 16) || tmp < 0) tmp = 0;
d->albumGain = tmp;
}

View File

@ -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