Skip to content

Commit 5699dec

Browse files
committed
pass parameters by const reference
1 parent 52b6d35 commit 5699dec

8 files changed

+28
-28
lines changed

src/config.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Config::has_notifications() const
6464
}
6565

6666
void
67-
Config::set_last_played_station(Glib::ustring station)
67+
Config::set_last_played_station(const Glib::ustring& station)
6868
{
6969
last_station = station;
7070
save_config();

src/config.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Config
2222
void set_config_file(const std::string& name);
2323
void load_config();
2424
bool has_last_station();
25-
void set_last_played_station(Glib::ustring station);
25+
void set_last_played_station(const Glib::ustring& station);
2626
Glib::ustring get_last_played_station() const;
2727
bool has_notifications() const;
2828

src/player.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Player::init(int argc, char** argv)
2222
}
2323

2424
void
25-
Player::play(Glib::ustring url, Glib::ustring station)
25+
Player::play(const Glib::ustring& url, const Glib::ustring& station)
2626
{
2727
init_streams(url, station);
2828
play();
@@ -68,7 +68,7 @@ Player::get_playbin()
6868
}
6969

7070
void
71-
Player::set_stream(Glib::ustring url)
71+
Player::set_stream(const Glib::ustring& url)
7272
{
7373
playbin->property_uri() = url;
7474
}
@@ -208,7 +208,7 @@ Player::has_station()
208208
}
209209

210210
void
211-
Player::init_streams(Glib::ustring data_url, Glib::ustring station)
211+
Player::init_streams(const Glib::ustring& data_url, const Glib::ustring& station)
212212
{
213213
bool ok;
214214

@@ -222,7 +222,7 @@ Player::init_streams(Glib::ustring data_url, Glib::ustring station)
222222
}
223223

224224
void
225-
Player::set_config(std::shared_ptr<Config> cfg)
225+
Player::set_config(const std::shared_ptr<Config>& cfg)
226226
{
227227
config = cfg;
228228
playlist.set_config(cfg);

src/player.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Player
3131
Player(const Player&) = delete;
3232

3333
bool init(int argc, char** argv);
34-
void play(Glib::ustring url, Glib::ustring station = Glib::ustring());
34+
void play(const Glib::ustring& url, const Glib::ustring& station = Glib::ustring());
3535
void play();
3636
void pause();
3737
void stop();
@@ -41,8 +41,8 @@ class Player
4141
bool has_station();
4242
Glib::RefPtr<PlayBin> get_playbin();
4343

44-
void init_streams(Glib::ustring data_url, Glib::ustring station);
45-
void set_config(std::shared_ptr<Config> cfg);
44+
void init_streams(const Glib::ustring& data_url, const Glib::ustring& station);
45+
void set_config(const std::shared_ptr<Config>& cfg);
4646

4747
std::shared_ptr<EventManager> em;
4848

@@ -57,7 +57,7 @@ class Player
5757
Glib::ustring current_station;
5858

5959
bool on_bus_message(const Glib::RefPtr<Gst::Bus>& bus, const Glib::RefPtr<Gst::Message>& message);
60-
void set_stream(Glib::ustring url);
60+
void set_stream(const Glib::ustring& url);
6161
void set_buffer_size(int size);
6262
void play_next_stream();
6363
};

src/playlist.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Playlist::init()
4646
}
4747

4848
std::tuple<bool, MediaStreams>
49-
Playlist::get_streams(std::string url)
49+
Playlist::get_streams(const std::string& url)
5050
{
5151
MediaStreams streams;
5252

@@ -84,13 +84,13 @@ Playlist::get_streams(std::string url)
8484
}
8585

8686
void
87-
Playlist::set_config(std::shared_ptr<Config> cfg)
87+
Playlist::set_config(const std::shared_ptr<Config>& cfg)
8888
{
8989
config = cfg;
9090
}
9191

9292
void
93-
Playlist::prepare_playlist_request(std::string url, bool only_headers)
93+
Playlist::prepare_playlist_request(const std::string& url, bool only_headers)
9494
{
9595
data.clear();
9696
curl_easy_reset(handle);
@@ -146,7 +146,7 @@ Playlist::get_content_type()
146146
}
147147

148148
MediaStreams
149-
Playlist::run_playlist_decoders(std::string url)
149+
Playlist::run_playlist_decoders(const std::string& url)
150150
{
151151
MediaStreams streams;
152152
bool extracted = false;

src/playlist.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class Playlist
3030
~Playlist();
3131

3232
bool init();
33-
std::tuple<bool, MediaStreams> get_streams(std::string url);
34-
void set_config(std::shared_ptr<Config> cfg);
33+
std::tuple<bool, MediaStreams> get_streams(const std::string& url);
34+
void set_config(const std::shared_ptr<Config>& cfg);
3535

3636
private:
3737
CURL* handle = nullptr;
@@ -46,10 +46,10 @@ class Playlist
4646

4747
std::map<PlaylistDecoderType, std::shared_ptr<PlaylistDecoder>> decoders;
4848

49-
void prepare_playlist_request(std::string url, bool only_headers);
49+
void prepare_playlist_request(const std::string& url, bool only_headers);
5050
long get_http_status();
5151
std::string get_content_type();
52-
MediaStreams run_playlist_decoders(std::string url);
52+
MediaStreams run_playlist_decoders(const std::string& url);
5353
bool has_prefix(const std::string& prefix, const std::string& str);
5454
PlaylistDecoderType guess_playlist_decoder_type();
5555

src/tray.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ RadioTrayLite::on_about_button()
155155
}
156156

157157
void
158-
RadioTrayLite::on_station_button(Glib::ustring group_name, Glib::ustring station_name, Glib::ustring station_url)
158+
RadioTrayLite::on_station_button(const Glib::ustring& group_name, const Glib::ustring& station_name, const Glib::ustring& station_url)
159159
{
160160
player->play(station_url, station_name);
161161

@@ -368,7 +368,7 @@ RadioTrayLite::set_current_station(bool turn_on)
368368
}
369369

370370
void
371-
RadioTrayLite::set_current_broadcast(Glib::ustring info)
371+
RadioTrayLite::set_current_broadcast(const Glib::ustring& info)
372372
{
373373
auto split = [](const Glib::ustring& info, size_t size) {
374374
if (info.size() <= size) {
@@ -402,7 +402,7 @@ RadioTrayLite::set_current_broadcast(Glib::ustring info)
402402
}
403403

404404
void
405-
RadioTrayLite::on_station_changed_signal(Glib::ustring station, StationState state)
405+
RadioTrayLite::on_station_changed_signal(const Glib::ustring& station, StationState state)
406406
{
407407
if (state == em->state) {
408408
return;
@@ -426,15 +426,15 @@ RadioTrayLite::on_station_changed_signal(Glib::ustring station, StationState sta
426426
}
427427

428428
void
429-
RadioTrayLite::on_broadcast_info_changed_signal(Glib::ustring /*station*/, Glib::ustring info)
429+
RadioTrayLite::on_broadcast_info_changed_signal(const Glib::ustring& /*station*/, const Glib::ustring& info)
430430
{
431431
set_current_broadcast(info);
432432

433433
LOG(DEBUG) << info;
434434
}
435435

436436
void
437-
RadioTrayLite::copy_default_bookmarks(std::string src_file)
437+
RadioTrayLite::copy_default_bookmarks(const std::string& src_file)
438438
{
439439
auto home = getenv("HOME");
440440
if (home == nullptr) {

src/tray.hpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class RadioTrayLite
7676

7777
void on_quit_button();
7878
void on_about_button();
79-
void on_station_button(Glib::ustring group_name, Glib::ustring station_name, Glib::ustring station_url);
79+
void on_station_button(const Glib::ustring& group_name, const Glib::ustring& station_name, const Glib::ustring& station_url);
8080
void on_reload_button();
8181
void on_current_station_button();
8282

@@ -88,12 +88,12 @@ class RadioTrayLite
8888
bool parse_bookmarks_file();
8989
void load_configuration();
9090
void set_current_station(bool turn_on);
91-
void set_current_broadcast(Glib::ustring info = Glib::ustring("Idle"));
91+
void set_current_broadcast(const Glib::ustring& info = Glib::ustring("Idle"));
9292

93-
void on_station_changed_signal(Glib::ustring station, StationState state);
94-
void on_broadcast_info_changed_signal(Glib::ustring station, Glib::ustring info);
93+
void on_station_changed_signal(const Glib::ustring& station, StationState state);
94+
void on_broadcast_info_changed_signal(const Glib::ustring& station, const Glib::ustring& info);
9595

96-
void copy_default_bookmarks(std::string src_file);
96+
void copy_default_bookmarks(const std::string& src_file);
9797

9898
bool file_exists(const std::string& dir, const std::string& file);
9999
bool dir_exists(const std::string& dir);

0 commit comments

Comments
 (0)