Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Issue 29712634: Noissue - add SplitString and TrimSpaces helpers (Closed)

Created:
March 1, 2018, 2:30 p.m. by sergei
Modified:
March 2, 2018, 10:27 a.m.
Base URL:
github.com:adblockplus/adblockpluscore
Visibility:
Public.

Description

- add `DependentString TrimSpaces(const String& value)` removing ASCII space characters on both sides of the argument - add `std::pair<DependentString, DependentString> SplitString(const String& value, String::size_type separatorPos)` splitting the string into two parts without a separator character Review: https://codereview.adblockplus.org/29712634 # It's extracted from https://codereview.adblockplus.org/29548581/

Patch Set 1 #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+120 lines, -0 lines) Patch
M compiled/String.h View 2 chunks +8 lines, -0 lines 0 comments Download
A compiled/String.cpp View 1 chunk +48 lines, -0 lines 6 comments Download
M meson.build View 1 chunk +1 line, -0 lines 0 comments Download
M test/compiled/String.cpp View 1 chunk +63 lines, -0 lines 0 comments Download

Messages

Total messages: 4
sergei
March 1, 2018, 3:03 p.m. (2018-03-01 15:03:13 UTC) #1
hub
https://codereview.adblockplus.org/29712634/diff/29712647/compiled/String.cpp File compiled/String.cpp (right): https://codereview.adblockplus.org/29712634/diff/29712647/compiled/String.cpp#newcode28 compiled/String.cpp:28: if (value[start] > u' ') we could write this ...
March 1, 2018, 6:40 p.m. (2018-03-01 18:40:07 UTC) #2
sergei
https://codereview.adblockplus.org/29712634/diff/29712647/compiled/String.cpp File compiled/String.cpp (right): https://codereview.adblockplus.org/29712634/diff/29712647/compiled/String.cpp#newcode28 compiled/String.cpp:28: if (value[start] > u' ') On 2018/03/01 18:40:07, hub ...
March 1, 2018, 9:14 p.m. (2018-03-01 21:14:12 UTC) #3
hub
March 1, 2018, 10:15 p.m. (2018-03-01 22:15:44 UTC) #4
LGTM

https://codereview.adblockplus.org/29712634/diff/29712647/compiled/String.cpp
File compiled/String.cpp (right):

https://codereview.adblockplus.org/29712634/diff/29712647/compiled/String.cpp...
compiled/String.cpp:28: if (value[start] > u' ')
On 2018/03/01 21:14:12, sergei wrote:
> On 2018/03/01 18:40:07, hub wrote:
> > we could write this loop as `for (; start < end && value[start] <= u' ';
> > ++start)`
> > 
> > Even though I'm not sure if the compiler would generate more efficient code.
> 
> Yes, but I rather wanted to separate that comparison in order to improve the
> readability (pretty subjective though) and because I thought that perhaps that
> condition could be changed, so it will be easier to do it. If you want I can
> change it of course.

Acknowledged.

https://codereview.adblockplus.org/29712634/diff/29712647/compiled/String.cpp...
compiled/String.cpp:45: };
On 2018/03/01 21:14:12, sergei wrote:
> On 2018/03/01 18:40:07, hub wrote:
> > what if secondBeginPos > value.length() ? since size_type is unsigned, it
> would
> > lead to undefined behaviour
> 
> value.length(), secondBeginPos and len (the third arg of DependentString ctr)
> are all unsigned integers which can represent the values, AFAIR (I googled,
>
https://stackoverflow.com/questions/28779803/is-subtracting-larger-unsigned-v...,
> it's the same in C++14, the footnote is 48, though) the result of len should
be
> defined.

Acknowledged.

Powered by Google App Engine
This is Rietveld