|
|
Chromium Code Reviews|
Created:
3 years, 11 months ago by pilgrim_google Modified:
3 years, 11 months ago CC:
blink-reviews, blink-reviews-wtf_chromium.org, chromium-reviews, Mikhail Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
DescriptionMigrate WTF::Vector::append() to ::push_back() in WTF::HexNumber
As discussed on platform-architecture-dev [0], there is interest in
normalizing the methods of WTF classes to better align with std classes.
This CL uses template specialization on WTF::HexNumber::appendByteAsHex,
which needs to support classes (like WTF::Vector) that are being
migrated to push_back() while other classes (like WTF::StringBuilder)
are still using an append() method.
There are no functional changes.
[0] https://groups.google.com/a/chromium.org/d/topic/platform-architecture-dev/I7jnz4p1h84/discussion
BUG=662431
Review-Url: https://codereview.chromium.org/2622363005
Cr-Commit-Position: refs/heads/master@{#446345}
Committed: https://chromium.googlesource.com/chromium/src/+/cb3a30a6acb4e3e774f9c0d416bb90c270065364
Patch Set 1 #Patch Set 2 : different syntax, still doesn't compile #Patch Set 3 : jsbell's variation #
Total comments: 1
Patch Set 4 : compiles, ship to production #
Total comments: 1
Patch Set 5 : switch HexNumber::appendUnsignedAsHexFixedSize to static function for less partial template special… #
Total comments: 3
Patch Set 6 : be as specific as possible in Vector override methods in HexNumber #
Total comments: 1
Patch Set 7 : remove template, rely on function overload resolution for Vector-specific methods #Messages
Total messages: 52 (29 generated)
The CQ bit was checked by pilgrim@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
pilgrim@chromium.org changed reviewers: + esprehn@chromium.org, haraken@chromium.org, jsbell@chromium.org, yutak@chromium.org
This does not currently compile. The idea is sound but I can't get the syntax right. Help?
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_chromeos_ozone_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
The CQ bit was checked by pilgrim@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: cast_shell_android on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/cast_shell_a...) linux_chromium_chromeos_ozone_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...) mac_chromium_compile_dbg_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_comp...)
The CQ bit was checked by pilgrim@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: android_compile_dbg on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/android_comp...)
https://codereview.chromium.org/2622363005/diff/40001/third_party/WebKit/Sour... File third_party/WebKit/Source/wtf/HexNumber.h (right): https://codereview.chromium.org/2622363005/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/wtf/HexNumber.h:51: HexConversionMode mode = Uppercase) { This should be just `HexConversionMode mode` (i.e. drop `= Uppercase`) - apparently it inherits that from the specialized template definition. Builds fine for me with that.
The CQ bit was checked by pilgrim@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
OK, this is ready for review.
LGTM
I just have an optional suggestion; your patch LGTM as-is. https://codereview.chromium.org/2622363005/diff/60001/third_party/WebKit/Sour... File third_party/WebKit/Source/wtf/HexNumber.h (right): https://codereview.chromium.org/2622363005/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/wtf/HexNumber.h:49: inline void appendByteAsHex<Vector<LChar>>(unsigned char byte, Is just specializing for Vector<LChar> sufficient? It might be worth considering to do Vector<T> partial specialization here (with a templated class with a static member function), but I agree that doing that could be overly complex.
I'd prefer we made this generic on Vector<T> instead of LChar.
On 2017/01/13 07:43:07, esprehn wrote: > I'd prefer we made this generic on Vector<T> instead of LChar. As noted by yutak, this would require converting this to a templated class with a static member function. Partial specialization of template functions is not permitted. Given that this is temporary (i.e. I think the plan is to rip out the specialization once everything is converted to push_back?) what do we want the end state for the code to be - functions or class statics?
On 2017/01/13 at 17:13:44, jsbell wrote: > On 2017/01/13 07:43:07, esprehn wrote: > > I'd prefer we made this generic on Vector<T> instead of LChar. > > As noted by yutak, this would require converting this to a templated class with a static member function. Partial specialization of template functions is not permitted. > > Given that this is temporary (i.e. I think the plan is to rip out the specialization once everything is converted to push_back?) what do we want the end state for the code to be - functions or class statics? I don't think we're going to rename StringBuilder::append to push_back. std::string has append() not push_back().
On 2017/01/13 17:26:44, esprehn wrote: > On 2017/01/13 at 17:13:44, jsbell wrote: > > On 2017/01/13 07:43:07, esprehn wrote: > > > I'd prefer we made this generic on Vector<T> instead of LChar. > > > > As noted by yutak, this would require converting this to a templated class > with a static member function. Partial specialization of template functions is > not permitted. > > > > Given that this is temporary (i.e. I think the plan is to rip out the > specialization once everything is converted to push_back?) what do we want the > end state for the code to be - functions or class statics? > > I don't think we're going to rename StringBuilder::append to push_back. > std::string has append() not push_back(). Ah, thanks. So... you're leaning towards introducing a HexNumber template class with statics? Looks like there are only ~20 uses of the append*AsHex*() functions, so not too terrible.
On 2017/01/13 at 18:01:13, jsbell wrote:
> On 2017/01/13 17:26:44, esprehn wrote:
> > On 2017/01/13 at 17:13:44, jsbell wrote:
> > > On 2017/01/13 07:43:07, esprehn wrote:
> > > > I'd prefer we made this generic on Vector<T> instead of LChar.
> > >
> > > As noted by yutak, this would require converting this to a templated class
> > with a static member function. Partial specialization of template functions
is
> > not permitted.
> > >
> > > Given that this is temporary (i.e. I think the plan is to rip out the
> > specialization once everything is converted to push_back?) what do we want
the
> > end state for the code to be - functions or class statics?
> >
> > I don't think we're going to rename StringBuilder::append to push_back.
> > std::string has append() not push_back().
>
> Ah, thanks.
>
> So... you're leaning towards introducing a HexNumber template class with
statics?
>
> Looks like there are only ~20 uses of the append*AsHex*() functions, so not
too terrible.
Sure, we hide that inside the function like:
appendAsHex(T&, ...) {
Adapter<T>:append(...);
}
you can also detect the existence of a function using some template magic, but
it's a bit ugly looking.
The CQ bit was checked by pilgrim@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
please re-review
https://codereview.chromium.org/2622363005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/wtf/HexNumber.h (right): https://codereview.chromium.org/2622363005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/wtf/HexNumber.h:51: Vector<T>& destination, Partial specialization of functions is forbidden, but partial specialization of static methods is just fine. Thanks, C++! https://codereview.chromium.org/2622363005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/wtf/HexNumber.h:102: using WTF::HexNumber; Question for the architecture folks: Given that this CL is touching every use of this API anyway, do we want to keep the 'using' or should we require callers to be explicit about the WTF namespace?
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
https://codereview.chromium.org/2622363005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/wtf/HexNumber.h (right): https://codereview.chromium.org/2622363005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/wtf/HexNumber.h:51: Vector<T>& destination, On 2017/01/19 17:52:30, jsbell wrote: > Partial specialization of functions is forbidden, but partial specialization of > static methods is just fine. Thanks, C++! Strictly speaking, this isn't partial specialization, but function overloading. This can be done in non-member functions, too.
On 2017/01/20 at 04:46:33, yutak wrote: > https://codereview.chromium.org/2622363005/diff/80001/third_party/WebKit/Sour... > File third_party/WebKit/Source/wtf/HexNumber.h (right): > > https://codereview.chromium.org/2622363005/diff/80001/third_party/WebKit/Sour... > third_party/WebKit/Source/wtf/HexNumber.h:51: Vector<T>& destination, > On 2017/01/19 17:52:30, jsbell wrote: > > Partial specialization of functions is forbidden, but partial specialization of > > static methods is just fine. Thanks, C++! > > Strictly speaking, this isn't partial specialization, but > function overloading. This can be done in non-member functions, > too. Can we be explicit and have Vector<UChar>, Vector<LChar>, etc. here? There shouldn't be many types of Vector this function needs to handle, we can write them out.
On 2017/01/20 04:52:57, esprehn wrote: > Can we be explicit and have Vector<UChar>, Vector<LChar>, etc. here? There > shouldn't be many types of Vector this function needs to handle, we can write > them out. Isn't this the opposite of the guidance in #24?
Please re-review.
The CQ bit was checked by pilgrim@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: cast_shell_android on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/cast_shell_a...) linux_chromium_compile_dbg_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
https://codereview.chromium.org/2622363005/diff/100001/third_party/WebKit/Sou... File third_party/WebKit/Source/wtf/HexNumber.h (right): https://codereview.chromium.org/2622363005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/wtf/HexNumber.h:49: template static inline void appendByteAsHex( If you intend to specialize a function template, you should replace "template" with "template <>". (The syntax "template void func();" is for explicit instantiation of a function template. In this case it must not have a function body.)
LGTM except for the comment above.
On 2017/01/25 at 05:33:28, yutak wrote: > https://codereview.chromium.org/2622363005/diff/100001/third_party/WebKit/Sou... > File third_party/WebKit/Source/wtf/HexNumber.h (right): > > https://codereview.chromium.org/2622363005/diff/100001/third_party/WebKit/Sou... > third_party/WebKit/Source/wtf/HexNumber.h:49: template static inline void appendByteAsHex( > If you intend to specialize a function template, you should replace > "template" with "template <>". > > (The syntax "template void func();" is for explicit instantiation > of a function template. In this case it must not have a function > body.) That gives me a compile-time error: In file included from ../../third_party/WebKit/Source/wtf/text/WTFString.cpp:28: ../../third_party/WebKit/Source/wtf/HexNumber.h:49:34: error: explicit specialization of 'appendByteAsHex' in class scope template <> static inline void appendByteAsHex( ^ 1 error generated.
On 2017/01/25 15:05:15, pilgrim_google wrote: > On 2017/01/25 at 05:33:28, yutak wrote: > > > https://codereview.chromium.org/2622363005/diff/100001/third_party/WebKit/Sou... > > File third_party/WebKit/Source/wtf/HexNumber.h (right): > > > > > https://codereview.chromium.org/2622363005/diff/100001/third_party/WebKit/Sou... > > third_party/WebKit/Source/wtf/HexNumber.h:49: template static inline void > appendByteAsHex( > > If you intend to specialize a function template, you should replace > > "template" with "template <>". > > > > (The syntax "template void func();" is for explicit instantiation > > of a function template. In this case it must not have a function > > body.) > > That gives me a compile-time error: > > In file included from ../../third_party/WebKit/Source/wtf/text/WTFString.cpp:28: > ../../third_party/WebKit/Source/wtf/HexNumber.h:49:34: error: explicit > specialization of 'appendByteAsHex' in class scope > template <> static inline void appendByteAsHex( > ^ > 1 error generated. Ah sorry, in that case, I think you should just remove "template". That will make the function overloaded, and during the overload resolution, non-templated functions will be preferred over templated ones, so that should work fine.
The CQ bit was checked by pilgrim@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from haraken@chromium.org, yutak@chromium.org Link to the patchset: https://codereview.chromium.org/2622363005/#ps120001 (title: "remove template, rely on function overload resolution for Vector-specific methods")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch.
Bot data: {"patchset_id": 120001, "attempt_start_ts": 1485442930442220,
"parent_rev": "4aa65a956762bfc23d791bf360d60fe944b84506", "commit_rev":
"cb3a30a6acb4e3e774f9c0d416bb90c270065364"}
Message was sent while issue was closed.
Description was changed from ========== Migrate WTF::Vector::append() to ::push_back() in WTF::HexNumber As discussed on platform-architecture-dev [0], there is interest in normalizing the methods of WTF classes to better align with std classes. This CL uses template specialization on WTF::HexNumber::appendByteAsHex, which needs to support classes (like WTF::Vector) that are being migrated to push_back() while other classes (like WTF::StringBuilder) are still using an append() method. There are no functional changes. [0] https://groups.google.com/a/chromium.org/d/topic/platform-architecture-dev/I7... BUG=662431 ========== to ========== Migrate WTF::Vector::append() to ::push_back() in WTF::HexNumber As discussed on platform-architecture-dev [0], there is interest in normalizing the methods of WTF classes to better align with std classes. This CL uses template specialization on WTF::HexNumber::appendByteAsHex, which needs to support classes (like WTF::Vector) that are being migrated to push_back() while other classes (like WTF::StringBuilder) are still using an append() method. There are no functional changes. [0] https://groups.google.com/a/chromium.org/d/topic/platform-architecture-dev/I7... BUG=662431 Review-Url: https://codereview.chromium.org/2622363005 Cr-Commit-Position: refs/heads/master@{#446345} Committed: https://chromium.googlesource.com/chromium/src/+/cb3a30a6acb4e3e774f9c0d416bb... ==========
Message was sent while issue was closed.
Committed patchset #7 (id:120001) as https://chromium.googlesource.com/chromium/src/+/cb3a30a6acb4e3e774f9c0d416bb... |
