mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 05:17:34 +00:00
Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
This commit is contained in:
parent
e5f09ea170
commit
3f3f45580a
762 changed files with 8315 additions and 8316 deletions
|
@ -30,7 +30,7 @@ void AlbumCoverVisualizationWidget::paint_event(GUI::PaintEvent& event)
|
|||
painter.draw_scaled_bitmap(fitted_rect, *m_album_cover, m_album_cover->rect(), 1.0f);
|
||||
} else {
|
||||
if (!m_serenity_bg)
|
||||
m_serenity_bg = Gfx::Bitmap::try_load_from_file("/res/wallpapers/sunset-retro.png").release_value_but_fixme_should_propagate_errors();
|
||||
m_serenity_bg = Gfx::Bitmap::try_load_from_file("/res/wallpapers/sunset-retro.png"sv).release_value_but_fixme_should_propagate_errors();
|
||||
painter.draw_scaled_bitmap(frame_inner_rect(), *m_serenity_bg, m_serenity_bg->rect(), 1.0f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ NonnullOwnPtr<M3UParser> M3UParser::from_file(const String path)
|
|||
auto file_result = Core::File::open(path, Core::OpenMode::ReadOnly);
|
||||
VERIFY(!file_result.is_error());
|
||||
auto contents = file_result.value()->read_all();
|
||||
auto use_utf8 = path.ends_with(".m3u8", CaseSensitivity::CaseInsensitive);
|
||||
auto use_utf8 = path.ends_with(".m3u8"sv, CaseSensitivity::CaseInsensitive);
|
||||
return from_memory(String { contents, NoChomp }, use_utf8);
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ NonnullOwnPtr<Vector<M3UEntry>> M3UParser::parse(bool include_extended_info)
|
|||
return {};
|
||||
};
|
||||
|
||||
if (auto ext_inf = tag("#EXTINF:"); ext_inf.has_value()) {
|
||||
if (auto ext_inf = tag("#EXTINF:"sv); ext_inf.has_value()) {
|
||||
auto separator = ext_inf.value().find(',');
|
||||
VERIFY(separator.has_value());
|
||||
auto seconds = ext_inf.value().substring_view(0, separator.value());
|
||||
|
@ -78,15 +78,15 @@ NonnullOwnPtr<Vector<M3UEntry>> M3UParser::parse(bool include_extended_info)
|
|||
// TODO: support the alternative, non-standard #EXTINF value of a key=value dictionary
|
||||
continue;
|
||||
}
|
||||
if (auto playlist = tag("#PLAYLIST:"); playlist.has_value())
|
||||
if (auto playlist = tag("#PLAYLIST:"sv); playlist.has_value())
|
||||
m_parsed_playlist_title = move(playlist.value());
|
||||
else if (auto ext_grp = tag("#EXTGRP:"); ext_grp.has_value())
|
||||
else if (auto ext_grp = tag("#EXTGRP:"sv); ext_grp.has_value())
|
||||
metadata_for_next_file.group_name = move(ext_grp.value());
|
||||
else if (auto ext_alb = tag("#EXTALB:"); ext_alb.has_value())
|
||||
else if (auto ext_alb = tag("#EXTALB:"sv); ext_alb.has_value())
|
||||
metadata_for_next_file.album_title = move(ext_alb.value());
|
||||
else if (auto ext_art = tag("#EXTART:"); ext_art.has_value())
|
||||
else if (auto ext_art = tag("#EXTART:"sv); ext_art.has_value())
|
||||
metadata_for_next_file.album_artist = move(ext_art.value());
|
||||
else if (auto ext_genre = tag("#EXTGENRE:"); ext_genre.has_value())
|
||||
else if (auto ext_genre = tag("#EXTGENRE:"sv); ext_genre.has_value())
|
||||
metadata_for_next_file.album_genre = move(ext_genre.value());
|
||||
// TODO: Support M3A files (M3U files with embedded mp3 files)
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ void Player::play_file_path(String const& path)
|
|||
return;
|
||||
|
||||
if (!Core::File::exists(path)) {
|
||||
audio_load_error(path, "File does not exist");
|
||||
audio_load_error(path, "File does not exist"sv);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -71,8 +71,8 @@ void Player::play_file_path(String const& path)
|
|||
|
||||
bool Player::is_playlist(String const& path)
|
||||
{
|
||||
return (path.ends_with(".m3u", AK::CaseSensitivity::CaseInsensitive)
|
||||
|| path.ends_with(".m3u8", AK::CaseSensitivity::CaseInsensitive));
|
||||
return (path.ends_with(".m3u"sv, AK::CaseSensitivity::CaseInsensitive)
|
||||
|| path.ends_with(".m3u8"sv, AK::CaseSensitivity::CaseInsensitive));
|
||||
}
|
||||
|
||||
void Player::set_play_state(PlayState state)
|
||||
|
|
|
@ -43,11 +43,11 @@ SoundPlayerWidgetAdvancedView::SoundPlayerWidgetAdvancedView(GUI::Window& window
|
|||
|
||||
m_player_view->set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
m_play_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/play.png").release_value_but_fixme_should_propagate_errors();
|
||||
m_pause_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/pause.png").release_value_but_fixme_should_propagate_errors();
|
||||
m_stop_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/stop.png").release_value_but_fixme_should_propagate_errors();
|
||||
m_back_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png").release_value_but_fixme_should_propagate_errors();
|
||||
m_next_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors();
|
||||
m_play_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/play.png"sv).release_value_but_fixme_should_propagate_errors();
|
||||
m_pause_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/pause.png"sv).release_value_but_fixme_should_propagate_errors();
|
||||
m_stop_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/stop.png"sv).release_value_but_fixme_should_propagate_errors();
|
||||
m_back_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"sv).release_value_but_fixme_should_propagate_errors();
|
||||
m_next_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"sv).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
m_visualization = m_player_view->add<BarsVisualizationWidget>();
|
||||
|
||||
|
@ -224,7 +224,7 @@ void SoundPlayerWidgetAdvancedView::volume_changed(double volume)
|
|||
void SoundPlayerWidgetAdvancedView::playlist_loaded(StringView path, bool loaded)
|
||||
{
|
||||
if (!loaded) {
|
||||
GUI::MessageBox::show(&m_window, String::formatted("Could not load playlist at \"{}\".", path), "Error opening playlist", GUI::MessageBox::Type::Error);
|
||||
GUI::MessageBox::show(&m_window, String::formatted("Could not load playlist at \"{}\".", path), "Error opening playlist"sv, GUI::MessageBox::Type::Error);
|
||||
return;
|
||||
}
|
||||
set_playlist_visible(true);
|
||||
|
@ -233,6 +233,6 @@ void SoundPlayerWidgetAdvancedView::playlist_loaded(StringView path, bool loaded
|
|||
|
||||
void SoundPlayerWidgetAdvancedView::audio_load_error(StringView path, StringView error_string)
|
||||
{
|
||||
GUI::MessageBox::show(&m_window, String::formatted("Failed to load audio file: {} ({})", path, error_string.is_null() ? "Unknown error" : error_string),
|
||||
"Filetype error", GUI::MessageBox::Type::Error);
|
||||
GUI::MessageBox::show(&m_window, String::formatted("Failed to load audio file: {} ({})", path, error_string.is_null() ? "Unknown error"sv : error_string),
|
||||
"Filetype error"sv, GUI::MessageBox::Type::Error);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
TRY(Core::System::pledge("stdio recvfd sendfd rpath thread"));
|
||||
|
||||
auto app_icon = GUI::Icon::default_icon("app-sound-player");
|
||||
auto app_icon = GUI::Icon::default_icon("app-sound-player"sv);
|
||||
|
||||
auto window = TRY(GUI::Window::try_create());
|
||||
window->set_title("Sound Player");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue