Skip to content

Commit e906711

Browse files
committed
refactor
1 parent 132928b commit e906711

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/ui/SongListLayer.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void SongListLayer::addSongsToScrollLayer(geode::ScrollLayer* scrollLayer, SongM
5959

6060
songData.displayName = SongListLayer::generateDisplayName(songData);
6161

62-
if (SAVED("songListSortSongLength")) songData.songLength = SongListLayer::getLength(songFilePath, reverse);
62+
if (SAVED("songListSortSongLength")) songData.songLength = SongListLayer::getLength(songData.actualFilePath, reverse);
6363

6464
if (!queryString.empty()) {
6565
const bool contains = geode::utils::string::contains(geode::utils::string::toLower(songData.displayName), geode::utils::string::toLower(queryString));
@@ -604,20 +604,18 @@ bool SongListLayer::songLength(MLRSongCell* a, MLRSongCell* b, const bool revers
604604
return a->m_songData.actualFilePath < b->m_songData.actualFilePath;
605605
}
606606

607-
unsigned int SongListLayer::getLength(const std::filesystem::path &path, const bool reverse) {
607+
unsigned int SongListLayer::getLength(const std::string& path, const bool reverse) {
608608
const double extreme = reverse ? std::numeric_limits<double>::min() : std::numeric_limits<double>::max();
609609
ma_decoder decoder;
610-
if (ma_decoder_init_file(path.string().c_str(), nullptr, &decoder) != MA_SUCCESS) {
611-
return extreme;
612-
}
610+
if (ma_decoder_init_file(path.c_str(), nullptr, &decoder) != MA_SUCCESS) return extreme;
613611

614612
ma_uint64 frames = 0;
615613
if (ma_decoder_get_length_in_pcm_frames(&decoder, &frames) != MA_SUCCESS) {
616614
ma_decoder_uninit(&decoder);
617615
return extreme;
618616
}
619617

620-
ma_uint32 sampleRate = decoder.outputSampleRate;
618+
const ma_uint32 sampleRate = decoder.outputSampleRate;
621619
ma_decoder_uninit(&decoder);
622620

623621
if (sampleRate == 0) return extreme;

src/ui/SongListLayer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class SongListLayer final : public geode::Popup<const std::string&> {
4141
static bool dateAdded(MLRSongCell* a, MLRSongCell* b, bool reverse);
4242
static bool songLength(MLRSongCell* a, MLRSongCell* b, bool reverse);
4343

44-
static unsigned int getLength(const std::filesystem::path &path, const bool reverse);
44+
static unsigned int getLength(const std::string& path, const bool reverse);
4545

4646
void update(float) override;
4747
};

0 commit comments

Comments
 (0)