Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Pass std::string by const ref where possible. #2558

Merged
merged 1 commit into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion srtcore/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4475,7 +4475,7 @@ void dellogfa(LogFA fa)
srt_logger_config.enabled_fa.set(fa, false);
}

void resetlogfa(set<LogFA> fas)
void resetlogfa(const set<LogFA>& fas)
{
ScopedLock gg(srt_logger_config.mutex);
for (int i = 0; i <= SRT_LOGFA_LASTNONE; ++i)
Expand Down
2 changes: 1 addition & 1 deletion srtcore/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ std::string TransmissionEventStr(ETransmissionEvent ev)
return vals[ev];
}

bool SrtParseConfig(string s, SrtConfig& w_config)
bool SrtParseConfig(const string& s, SrtConfig& w_config)
{
using namespace std;

Expand Down
2 changes: 1 addition & 1 deletion srtcore/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -1414,7 +1414,7 @@ inline std::string SrtVersionString(int version)
return buf;
}

bool SrtParseConfig(std::string s, SrtConfig& w_config);
bool SrtParseConfig(const std::string& s, SrtConfig& w_config);

} // namespace srt

Expand Down
4 changes: 2 additions & 2 deletions srtcore/congctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class SrtCongestion

struct IsName
{
std::string n;
IsName(std::string nn): n(nn) {}
const std::string n;
IsName(const std::string& nn): n(nn) {}
bool operator()(NamePtr np) { return n == np.first; }
};

Expand Down
4 changes: 2 additions & 2 deletions srtcore/packetfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ using namespace std;
using namespace srt_logging;
using namespace srt::sync;

bool srt::ParseFilterConfig(string s, SrtFilterConfig& w_config, PacketFilter::Factory** ppf)
bool srt::ParseFilterConfig(const string& s, SrtFilterConfig& w_config, PacketFilter::Factory** ppf)
{
if (!SrtParseConfig(s, (w_config)))
return false;
Expand All @@ -43,7 +43,7 @@ bool srt::ParseFilterConfig(string s, SrtFilterConfig& w_config, PacketFilter::F
return true;
}

bool srt::ParseFilterConfig(string s, SrtFilterConfig& w_config)
bool srt::ParseFilterConfig(const string& s, SrtFilterConfig& w_config)
{
return ParseFilterConfig(s, (w_config), NULL);
}
Expand Down
4 changes: 2 additions & 2 deletions srtcore/packetfilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class PacketFilter
virtual ~Factory();
};
private:
friend bool ParseFilterConfig(std::string s, SrtFilterConfig& out, PacketFilter::Factory** ppf);
friend bool ParseFilterConfig(const std::string& s, SrtFilterConfig& out, PacketFilter::Factory** ppf);

template <class Target>
class Creator: public Factory
Expand Down Expand Up @@ -212,7 +212,7 @@ bool CheckFilterCompat(SrtFilterConfig& w_agent, SrtFilterConfig peer);
inline void PacketFilter::feedSource(CPacket& w_packet) { SRT_ASSERT(m_filter); return m_filter->feedSource((w_packet)); }
inline SRT_ARQLevel PacketFilter::arqLevel() { SRT_ASSERT(m_filter); return m_filter->arqLevel(); }

bool ParseFilterConfig(std::string s, SrtFilterConfig& out, PacketFilter::Factory** ppf);
bool ParseFilterConfig(const std::string& s, SrtFilterConfig& out, PacketFilter::Factory** ppf);

} // namespace srt

Expand Down
2 changes: 1 addition & 1 deletion srtcore/packetfilter_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct SrtPacket
};


bool ParseFilterConfig(std::string s, SrtFilterConfig& w_config);
bool ParseFilterConfig(const std::string& s, SrtFilterConfig& w_config);


class SrtPacketFilterBase
Expand Down
2 changes: 1 addition & 1 deletion srtcore/udt.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ namespace srt
SRT_API void setloglevel(srt_logging::LogLevel::type ll);
SRT_API void addlogfa(srt_logging::LogFA fa);
SRT_API void dellogfa(srt_logging::LogFA fa);
SRT_API void resetlogfa(std::set<srt_logging::LogFA> fas);
SRT_API void resetlogfa(const std::set<srt_logging::LogFA>& fas);
SRT_API void resetlogfa(const int* fara, size_t fara_size);
SRT_API void setlogstream(std::ostream& stream);
SRT_API void setloghandler(void* opaque, SRT_LOG_HANDLER_FN* handler);
Expand Down