RESOLVED FIXED 118503
Improve StringImpl::constructInternal() method
https://bugs.webkit.org/show_bug.cgi?id=118503
Summary Improve StringImpl::constructInternal() method
Mikhail Pozdnyakov
Reported 2013-07-09 06:45:53 PDT
StringImpl::constructInternal does the following (this code had been located previously inside tryCreateUninitializedForce) if (sizeof(CharType) == sizeof(char)) return adoptRef(new (NotNull, impl) StringImpl(length, Force8BitConstructor)); return adoptRef(new (NotNull, impl) StringImpl(length)); Compiler has to compile both branches even though optimizer will than remove one of those, and as the function is inline it can affect slightly the compilation time. Would be nice to have compile-time polymorphism in the constructor already.
Attachments
patch (5.05 KB, patch)
2013-07-09 07:03 PDT, Mikhail Pozdnyakov
no flags
alternate patch (2.37 KB, patch)
2013-07-11 01:19 PDT, Mikhail Pozdnyakov
no flags
same as before (try EWS) (2.37 KB, patch)
2013-07-11 01:48 PDT, Mikhail Pozdnyakov
benjamin: review+
Mikhail Pozdnyakov
Comment 1 2013-07-09 07:03:58 PDT
Mikhail Pozdnyakov
Comment 2 2013-07-10 14:19:56 PDT
Having had a discussion with Benjamin on IRC came to conclusion that this is not worthwhile as might affect code readability.
Mikhail Pozdnyakov
Comment 3 2013-07-11 01:19:25 PDT
Created attachment 206434 [details] alternate patch Solves the problem without affecting code readability.
Mikhail Pozdnyakov
Comment 4 2013-07-11 01:47:01 PDT
EWS doe not run, might be because the bug is closed, reopening..
Mikhail Pozdnyakov
Comment 5 2013-07-11 01:48:44 PDT
Created attachment 206436 [details] same as before (try EWS)
Benjamin Poulain
Comment 6 2013-07-11 14:11:36 PDT
Comment on attachment 206436 [details] same as before (try EWS) I am not sure why you obsess on this branch :) But I don't see anything wrong with this. Note that the old code handle char and LChar.
Benjamin Poulain
Comment 7 2013-07-11 14:12:02 PDT
Comment on attachment 206436 [details] same as before (try EWS) View in context: https://bugs.webkit.org/attachment.cgi?id=206436&action=review > Source/WTF/ChangeLog:22 > + (WTF::StringImpl::reallocateInternal): > + * wtf/text/StringImpl.h: > + (WTF::StringImpl::StringImpl): > + (WTF::StringImpl::tryCreateUninitialized): > + (WTF::LChar): > + (WTF::UChar): Oh, don't forget to fix your changelog.
Mikhail Pozdnyakov
Comment 8 2013-07-12 09:41:22 PDT
Note You need to log in before you can comment on or make changes to this bug.