-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Update codebase from boost::string_view into std::string_view #4509
Changes from 30 commits
ba1da15
3850093
1141e0f
c966149
efaf7ae
92fda38
8c17a5c
eada2c3
4967121
6dbfd7f
e4015fd
be6e9be
9d9f40e
0c39f13
8da02e5
a433207
2cf0eb8
85e001d
88412ea
b780312
999d9c2
cee5ff8
ac77412
cfa960f
5313b13
204f9f4
d851b16
49968bf
a20907f
d3d309a
fcf1375
3cda316
ba99ab4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
|
||
#include <boost/beast/core/string.hpp> | ||
#include <functional> | ||
#include <string> | ||
|
||
namespace Json { | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,6 @@ | |
#include <ripple/server/SimpleWriter.h> | ||
|
||
#include <boost/algorithm/string/predicate.hpp> | ||
#include <boost/utility/in_place_factory.hpp> | ||
|
||
namespace ripple { | ||
|
||
|
@@ -829,7 +828,7 @@ OverlayImpl::getOverlayInfo() | |
auto version{sp->getVersion()}; | ||
if (!version.empty()) | ||
// Could move here if Json::value supported moving from strings | ||
pv[jss::version] = version; | ||
pv[jss::version] = std::string{version}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good place here for that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm okay |
||
} | ||
|
||
std::uint32_t minSeq, maxSeq; | ||
|
@@ -997,9 +996,9 @@ OverlayImpl::processValidatorList( | |
return true; | ||
}; | ||
|
||
auto key = req.target().substr(prefix.size()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd personally leave this alone. You're adding complexity for no real reason here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I leave type-deduction to auto, I'm not 100% sure if it is deduced as My observation is that construction of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I sympathize with your position, @nbougalis. But I think perhaps the conversion can be done a bit more cleanly like this:
Since the FWIW, I have a theory regarding the garbage values at the end of If you construct a For more details see the description of constructor 4 on this page: https://en.cppreference.com/w/cpp/string/basic_string_view/basic_string_view The lesson from this is that the only situation where a
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i missed this comment, thanks for the explanation Scott! yes, that makes sense |
||
std::string_view key = req.target().substr(prefix.size()); | ||
|
||
if (auto slash = key.find('/'); slash != boost::string_view::npos) | ||
if (auto slash = key.find('/'); slash != std::string_view::npos) | ||
{ | ||
auto verString = key.substr(0, slash); | ||
if (!boost::conversion::try_lexical_convert(verString, version)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you call the overload of
boost::regex_search
that takes two iterators, then you can leave the value as astd::string_view
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting observation!
boost provides the following typedefs for the
boost::smatch match;
variable. We use it to store the appropriate portion of the input. I couldn't find the correct type for this variable. Ideally, I'd needmatch_results<std::string_view::const_iterator>
to be the type ofmatch
.match_results<const char*>
is incorrect, because some inputs might not be null-terminated.match_results<std::string::const_iterator>
is type incompatible withstd:string_view value;
I need to use this overload for the regex_search function.
How can I work around this?