Skip to content

Commit 244baf8

Browse files
authored
Change string_view& to string_view by value (#44)
* changed sv usage from by reference to by value * changed sv usage from by reference to by value * changed sv usage from by reference to by value * changed sv usage from by reference to by value * changed sv usage from by reference to by value * changed sv usage from by reference to by value * changed sv usage from by reference to by value
1 parent 1726a1f commit 244baf8

17 files changed

+54
-50
lines changed

srcbpatch/actionscollection.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,15 +314,15 @@ void ActionsCollection::ReportError(const char* const message)
314314
throw std::runtime_error(message);
315315
}
316316

317-
void ActionsCollection::ReportDuplicateNameError(const std::string_view& aname)
317+
void ActionsCollection::ReportDuplicateNameError(const std::string_view aname)
318318
{
319319
std::stringstream ss;
320320
ss << "Duplicate name '" << aname << "' has been met in Actions file";
321321
ReportError(ss.str().c_str());
322322
}
323323

324324

325-
void ActionsCollection::ReportMissedNameError(const std::string_view& aname)
325+
void ActionsCollection::ReportMissedNameError(const std::string_view aname)
326326
{
327327
std::stringstream ss;
328328
ss << "Cannot find lexeme name '" << aname << "' in Actions file";

srcbpatch/actionscollection.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ class ActionsCollection final: public TJsonCallBack, public StreamReplacer
7575
/// throws error if we meet duplicate name of lexeme
7676
/// </summary>
7777
/// <param name="aname">duplicate name of lexeme</param>
78-
static void ReportDuplicateNameError(const std::string_view& aname);
78+
static void ReportDuplicateNameError(const std::string_view aname);
7979

8080
/// <summary>
8181
/// throws error if we cannot find lexeme for composite lexeme
8282
/// </summary>
8383
/// <param name="aname">nonexistent name of lexeme</param>
84-
static void ReportMissedNameError(const std::string_view& aname);
84+
static void ReportMissedNameError(const std::string_view aname);
8585

8686
/// <summary>
8787
/// parse array of either 10 based integers or array of hex based strings

srcbpatch/coloredconsole.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ namespace coloredconsole
4646
};
4747
#endif
4848

49-
void ColorizeWords(std::ostream& os, const std::string_view& sv)
49+
void ColorizeWords(std::ostream& os, const std::string_view sv)
5050
{
5151
static const std::string_view errorSV = "ERROR";
5252
static const std::string_view warningSV = "Warning";
@@ -90,7 +90,7 @@ namespace coloredconsole
9090
pos = sv.size();
9191
} // while (pos < sv.size())
9292

93-
}// void ColorizeWords(std::ostream& os, const std::string_view& sv)
93+
}// void ColorizeWords(std::ostream& os, const std::string_view sv)
9494

9595
} // namespace coloredconsole
9696

srcbpatch/coloredconsole.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace coloredconsole
1111
/// </summary>
1212
/// <param name="os"> std::cout actually</param>
1313
/// <param name="sv">string view to search ERROR and Warning words for colorization</param>
14-
void ColorizeWords(std::ostream& os, const std::string_view& sv);
14+
void ColorizeWords(std::ostream& os, const std::string_view sv);
1515

1616
template<typename T>
1717
struct is_char_array : std::false_type {}; // by default the type is not char array

srcbpatch/dictionary.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace bpatch
77
{
88

9-
std::unique_ptr<AbstractBinaryLexeme>& Dictionary::Lexeme(const std::string_view& aname) const
9+
std::unique_ptr<AbstractBinaryLexeme>& Dictionary::Lexeme(const std::string_view aname) const
1010
{
1111
if (auto it = dict.find(aname); it != dict.cend())
1212
{
@@ -16,13 +16,13 @@ std::unique_ptr<AbstractBinaryLexeme>& Dictionary::Lexeme(const std::string_view
1616
}
1717

1818

19-
AbstractLexemesPair Dictionary::LexemesPair(const std::string_view& anameSrc, const std::string_view& anameTrg) const
19+
AbstractLexemesPair Dictionary::LexemesPair(const std::string_view anameSrc, const std::string_view anameTrg) const
2020
{
2121
return {Lexeme(anameSrc), Lexeme(anameTrg)};
2222
}
2323

2424

25-
bool Dictionary::AddBinaryLexeme(const std::string_view& aname, std::unique_ptr<AbstractBinaryLexeme>&& alexeme)
25+
bool Dictionary::AddBinaryLexeme(const std::string_view aname, std::unique_ptr<AbstractBinaryLexeme>&& alexeme)
2626
{
2727
auto it = lexemes_.emplace(lexemes_.cend(), std::move(alexeme));
2828

srcbpatch/dictionary.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Dictionary final
1818
/// </summary>
1919
/// <param name="aname"> name of the lexeme from dictionary file</param>
2020
/// <returns>lexeme from dictionary file, or nullptr</returns>
21-
std::unique_ptr<AbstractBinaryLexeme>& Lexeme(const std::string_view& aname) const;
21+
std::unique_ptr<AbstractBinaryLexeme>& Lexeme(const std::string_view aname) const;
2222

2323

2424
/// <summary>
@@ -27,7 +27,7 @@ class Dictionary final
2727
/// <param name="anameSrc">name of the lexeme from dictionary file</param>
2828
/// <param name="anameTrg">name of the lexeme from dictionary file</param>
2929
/// <returns>lexeme from dictionary file, or nullptr</returns>
30-
AbstractLexemesPair LexemesPair(const std::string_view& anameSrc, const std::string_view& anameTrg) const;
30+
AbstractLexemesPair LexemesPair(const std::string_view anameSrc, const std::string_view anameTrg) const;
3131

3232

3333
/// <summary>
@@ -37,7 +37,7 @@ class Dictionary final
3737
/// <param name="alexeme">lexeme to store inside</param>
3838
/// <returns>true - if this lexeme is just added;
3939
/// false - if lexeme already was in the dictionary: new lexeme is lost</returns>
40-
bool AddBinaryLexeme(const std::string_view& aname, std::unique_ptr<AbstractBinaryLexeme>&& alexeme);
40+
bool AddBinaryLexeme(const std::string_view aname, std::unique_ptr<AbstractBinaryLexeme>&& alexeme);
4141

4242
protected:
4343
using LEXEMES_HOLDER = std::list<std::unique_ptr<AbstractBinaryLexeme>>;

srcbpatch/fileprocessing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ size_t WriteFileProcessing::Written() const noexcept
103103
return writeAt_;
104104
}
105105

106-
size_t WriteFileProcessing::WriteAndThrowIfFail(const string_view& sv)
106+
size_t WriteFileProcessing::WriteAndThrowIfFail(const string_view sv)
107107
{
108108
#ifdef __linux__
109109
const size_t written = fwrite_unlocked(sv.data(), sizeof(sv.data()[0]), sv.size(), stream_);

srcbpatch/fileprocessing.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,12 @@ class WriteFileProcessing : virtual public FileProcessing, public Writer
177177
size_t Written() const noexcept override; // the only way to get writeAt_
178178

179179
protected:
180-
size_t WriteAndThrowIfFail(const std::string_view& sv); // here writeAt_ could grow
180+
/// <summary>
181+
/// !unlocked! write file inside. Throws If the written amount do not equal to the requested
182+
/// </summary>
183+
/// <param name="sv"> data to write</param>
184+
/// <returns>written amount</returns>
185+
size_t WriteAndThrowIfFail(const std::string_view sv); // here writeAt_ could grow
181186

182187
/// <summary>
183188
/// write either full chunks only or everything if aEod was achieved

srcbpatch/flexiblecache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ FlexibleCache::FlexibleCache()
1212
}
1313

1414

15-
bool FlexibleCache::Accumulate(const string_view& adata)
15+
bool FlexibleCache::Accumulate(const string_view adata)
1616
{
1717
unique_ptr<Chunk>& activeChunk = *currentChunk;
1818

srcbpatch/flexiblecache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class FlexibleCache
3434
/// </summary>
3535
/// <param name="data"> data to accumulate</param>
3636
/// <returns>true if root chunk completely filled with data</returns>
37-
bool Accumulate(const std::string_view& adata);
37+
bool Accumulate(const std::string_view adata);
3838

3939

4040
/// <summary>

0 commit comments

Comments
 (0)