Skip to content

Commit

Permalink
Remove redundant casts
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaski committed Apr 22, 2024
1 parent 569bf63 commit 3edd218
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions ext/strawberry-tagreader/tagreaderworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ bool TagReaderWorker::HandleMessage(const spb::tagreader::Message &message, spb:
return success;
}
else if (message.has_read_file_request()) {
const QString filename = QString::fromUtf8(message.read_file_request().filename().data(), static_cast<qint64>(static_cast<qint64>(message.read_file_request().filename().size())));
const QString filename = QString::fromUtf8(message.read_file_request().filename().data(), static_cast<qint64>(message.read_file_request().filename().size()));
bool success = reader->ReadFile(filename, reply.mutable_read_file_response()->mutable_metadata());
return success;
}
Expand All @@ -72,7 +72,7 @@ bool TagReaderWorker::HandleMessage(const spb::tagreader::Message &message, spb:
return success;
}
else if (message.has_load_embedded_art_request()) {
const QString filename = QString::fromUtf8(message.load_embedded_art_request().filename().data(), static_cast<qint64>(static_cast<qint64>(message.load_embedded_art_request().filename().size())));
const QString filename = QString::fromUtf8(message.load_embedded_art_request().filename().data(), static_cast<qint64>(message.load_embedded_art_request().filename().size()));
QByteArray data = reader->LoadEmbeddedArt(filename);
reply.mutable_load_embedded_art_response()->set_data(data.constData(), data.size());
return true;
Expand All @@ -83,7 +83,7 @@ bool TagReaderWorker::HandleMessage(const spb::tagreader::Message &message, spb:
return success;
}
else if (message.has_save_song_playcount_to_file_request()) {
const QString filename = QString::fromUtf8(message.save_song_playcount_to_file_request().filename().data(), static_cast<qint64>(static_cast<qint64>(message.save_song_playcount_to_file_request().filename().size())));
const QString filename = QString::fromUtf8(message.save_song_playcount_to_file_request().filename().data(), static_cast<qint64>(message.save_song_playcount_to_file_request().filename().size()));
bool success = reader->SaveSongPlaycountToFile(filename, message.save_song_playcount_to_file_request().metadata());
reply.mutable_save_song_playcount_to_file_response()->set_success(success);
return success;
Expand Down
20 changes: 10 additions & 10 deletions src/analyzer/blockanalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,12 @@ QColor ensureContrast(const QColor &bg, const QColor &fg, int amount) {

// value is the best measure of contrast
// if there is enough difference in value already, return fg unchanged
if (dv > static_cast<int>(amount)) return fg;
if (dv > amount) return fg;

int ds = abs(bs - fs);

// saturation is good enough too. But not as good. TODO adapt this a little
if (ds > static_cast<int>(amount)) return fg;
if (ds > amount) return fg;

int dh = abs(bh - fh);

Expand All @@ -294,7 +294,7 @@ QColor ensureContrast(const QColor &bg, const QColor &fg, int amount) {
// low saturation on a low saturation is sad
const int tmp = 50 - fs;
fs = 50;
if (static_cast<int>(amount) > tmp) {
if (amount > tmp) {
amount -= tmp;
}
else {
Expand All @@ -310,25 +310,25 @@ QColor ensureContrast(const QColor &bg, const QColor &fg, int amount) {
if (amount > 0) adjustToLimits(bs, fs, amount);

// see if we need to adjust the hue
if (static_cast<int>(amount) > 0)
fh += static_cast<int>(amount); // cycles around;
if (amount > 0)
fh += amount; // cycles around;

return QColor::fromHsv(fh, fs, fv);
}

if (fv > bv && bv > static_cast<int>(amount)) {
return QColor::fromHsv(fh, fs, bv - static_cast<int>(amount));
if (fv > bv && bv > amount) {
return QColor::fromHsv(fh, fs, bv - amount);
}

if (fv < bv && fv > static_cast<int>(amount)) {
if (fv < bv && fv > amount) {
return QColor::fromHsv(fh, fs, fv - amount);
}

if (fv > bv && (255 - fv > static_cast<int>(amount))) {
if (fv > bv && (255 - fv > amount)) {
return QColor::fromHsv(fh, fs, fv + amount);
}

if (fv < bv && (255 - bv > static_cast<int>(amount))) {
if (fv < bv && (255 - bv > amount)) {
return QColor::fromHsv(fh, fs, bv + amount);
}

Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/boomanalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void BoomAnalyzer::resizeEvent(QResizeEvent *e) {
bands_ = qMin(static_cast<int>(static_cast<double>(width() + 1) / (kColumnWidth + 1)) + 1, kMaxBandCount);
scope_.resize(bands_);

F_ = static_cast<double>(HEIGHT) / (log10(256) * static_cast<double>(1.1) /*<- max. amplitude*/);
F_ = static_cast<double>(HEIGHT) / (log10(256) * 1.1 /*<- max. amplitude*/);

barPixmap_ = QPixmap(kColumnWidth - 2, HEIGHT);
canvas_ = QPixmap(size());
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/fht.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <QVector>
#include <QtMath>

FHT::FHT(uint n) : num_((n < 3) ? 0 : 1 << n), exp2_((n < 3) ? static_cast<int>(-1) : static_cast<int>(n)) {
FHT::FHT(uint n) : num_((n < 3) ? 0 : 1 << n), exp2_((n < 3) ? -1 : static_cast<int>(n)) {

if (n > 3) {
buf_vector_.resize(num_);
Expand Down

0 comments on commit 3edd218

Please sign in to comment.