mirror of
https://github.com/taglib/taglib.git
synced 2026-07-22 19:30:53 -04:00
Inspection: Code redundancies
This commit is contained in:
@@ -287,7 +287,7 @@ ByteVector TextIdentificationFrame::renderFields() const
|
||||
if(it != d->fieldList.cbegin())
|
||||
v.append(textDelimiter(encoding));
|
||||
|
||||
v.append((*it).data(encoding));
|
||||
v.append(it->data(encoding));
|
||||
}
|
||||
|
||||
return v;
|
||||
|
||||
@@ -553,7 +553,7 @@ Frame *FrameFactory::createFrameForProperty(const String &key, const StringList
|
||||
auto frame = new TextIdentificationFrame(frameID, String::UTF8);
|
||||
frame->setText(values);
|
||||
return frame;
|
||||
} if((frameID[0] == 'W') && (values.size() == 1)){ // URL frame (not WXXX); support only one value
|
||||
} if(frameID[0] == 'W' && values.size() == 1){ // URL frame (not WXXX); support only one value
|
||||
auto frame = new UrlLinkFrame(frameID);
|
||||
frame->setUrl(values.front());
|
||||
return frame;
|
||||
|
||||
@@ -300,7 +300,7 @@ bool ID3v2::Tag::isEmpty() const
|
||||
|
||||
Header *ID3v2::Tag::header() const
|
||||
{
|
||||
return &(d->header);
|
||||
return &d->header;
|
||||
}
|
||||
|
||||
ExtendedHeader *ID3v2::Tag::extendedHeader() const
|
||||
|
||||
@@ -238,10 +238,10 @@ bool MPEG::File::save(int tags, StripTags strip, ID3v2::Version version, Duplica
|
||||
insert(data, d->ID3v2Location, d->ID3v2OriginalSize);
|
||||
|
||||
if(d->APELocation >= 0)
|
||||
d->APELocation += (static_cast<long>(data.size()) - d->ID3v2OriginalSize);
|
||||
d->APELocation += static_cast<long>(data.size()) - d->ID3v2OriginalSize;
|
||||
|
||||
if(d->ID3v1Location >= 0)
|
||||
d->ID3v1Location += (static_cast<long>(data.size()) - d->ID3v2OriginalSize);
|
||||
d->ID3v1Location += static_cast<long>(data.size()) - d->ID3v2OriginalSize;
|
||||
|
||||
d->ID3v2OriginalSize = data.size();
|
||||
}
|
||||
@@ -294,7 +294,7 @@ bool MPEG::File::save(int tags, StripTags strip, ID3v2::Version version, Duplica
|
||||
insert(data, d->APELocation, d->APEOriginalSize);
|
||||
|
||||
if(d->ID3v1Location >= 0)
|
||||
d->ID3v1Location += (static_cast<long>(data.size()) - d->APEOriginalSize);
|
||||
d->ID3v1Location += static_cast<long>(data.size()) - d->APEOriginalSize;
|
||||
|
||||
d->APEOriginalSize = data.size();
|
||||
}
|
||||
@@ -445,17 +445,17 @@ offset_t MPEG::File::lastFrameOffset()
|
||||
|
||||
bool MPEG::File::hasID3v1Tag() const
|
||||
{
|
||||
return (d->ID3v1Location >= 0);
|
||||
return d->ID3v1Location >= 0;
|
||||
}
|
||||
|
||||
bool MPEG::File::hasID3v2Tag() const
|
||||
{
|
||||
return (d->ID3v2Location >= 0);
|
||||
return d->ID3v2Location >= 0;
|
||||
}
|
||||
|
||||
bool MPEG::File::hasAPETag() const
|
||||
{
|
||||
return (d->APELocation >= 0);
|
||||
return d->APELocation >= 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -210,7 +210,7 @@ void MPEG::Header::parse(File *file, offset_t offset, bool checkLength)
|
||||
}
|
||||
}
|
||||
|
||||
d->protectionEnabled = (static_cast<unsigned char>(data[1] & 0x01) == 0);
|
||||
d->protectionEnabled = static_cast<unsigned char>(data[1] & 0x01) == 0;
|
||||
|
||||
if(isADTS()) {
|
||||
static constexpr std::array sampleRates {
|
||||
@@ -262,8 +262,8 @@ void MPEG::Header::parse(File *file, offset_t offset, bool checkLength)
|
||||
},
|
||||
};
|
||||
|
||||
const int versionIndex = (d->version == Version1) ? 0 : 1;
|
||||
const int layerIndex = (d->layer > 0) ? d->layer - 1 : 0;
|
||||
const int versionIndex = d->version == Version1 ? 0 : 1;
|
||||
const int layerIndex = d->layer > 0 ? d->layer - 1 : 0;
|
||||
|
||||
// The bitrate index is encoded as the first 4 bits of the 3rd byte,
|
||||
// i.e. 1111xxxx
|
||||
@@ -300,9 +300,9 @@ void MPEG::Header::parse(File *file, offset_t offset, bool checkLength)
|
||||
|
||||
// TODO: Add mode extension for completeness
|
||||
|
||||
d->isOriginal = ((static_cast<unsigned char>(data[3]) & 0x04) != 0);
|
||||
d->isCopyrighted = ((static_cast<unsigned char>(data[3]) & 0x08) != 0);
|
||||
d->isPadded = ((static_cast<unsigned char>(data[2]) & 0x02) != 0);
|
||||
d->isOriginal = (static_cast<unsigned char>(data[3]) & 0x04) != 0;
|
||||
d->isCopyrighted = (static_cast<unsigned char>(data[3]) & 0x08) != 0;
|
||||
d->isPadded = (static_cast<unsigned char>(data[2]) & 0x02) != 0;
|
||||
|
||||
// Samples per frame
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ void MPEG::Properties::read(File *file, ReadStyle readStyle)
|
||||
}
|
||||
}
|
||||
bitRate = firstHeader.samplesPerFrame() != 0
|
||||
? static_cast<int>((bytesPerFrame * 8 * firstHeader.sampleRate())
|
||||
? static_cast<int>(bytesPerFrame * 8 * firstHeader.sampleRate()
|
||||
/ 1000 / firstHeader.samplesPerFrame())
|
||||
: 0;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ MPEG::XingHeader::~XingHeader() = default;
|
||||
|
||||
bool MPEG::XingHeader::isValid() const
|
||||
{
|
||||
return (d->type != Invalid && d->frames > 0 && d->size > 0);
|
||||
return d->type != Invalid && d->frames > 0 && d->size > 0;
|
||||
}
|
||||
|
||||
unsigned int MPEG::XingHeader::totalFrames() const
|
||||
|
||||
Reference in New Issue
Block a user