Skip to content

Commit

Permalink
[core] Pass std::string by const ref where possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsharabayko committed Nov 28, 2022
1 parent 053f179 commit 6c52f2d
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
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

0 comments on commit 6c52f2d

Please sign in to comment.