WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
97860
Make functions in Localizer class "const"
https://bugs.webkit.org/show_bug.cgi?id=97860
Summary
Make functions in Localizer class "const"
yosin
Reported
2012-09-27 21:57:52 PDT
Following functions in class Localizer[1] should have "const" specifier to use constant reference to Localizer object for code readability and allow optimization by compiler. - convertToLocalizedNumber() - convertFromLocalizedNumber() - localizedDecimalSeparator() - timeFormat() - shortTimeFormat() - timeAMPMLabels() Once we can use constant reference Localizer object, we should change use sites to use constant reference, please file another bug: - Localizer& Documenet::getLocalizer() - BaseMultipleFieldsDateAndTimeInputType::updateInnerTextValue() Localizer& localizer = element()->document()->getLocalizer(element()->computeInheritedLanguage()); - DateTimeEditBuilder member variable Localizer& m_localize - DateTimeEditElement::LayoutParameters LayoutParameters(Localizer& localizer, const StepRange& stepRange) Localizer& localizer - Maybe more = References = [1]
http://trac.webkit.org/browser/trunk/Source/WebCore/platform/text/Localizer.h
Attachments
Add attachment
proposed patch, testcase, etc.
Alexey Proskuryakov
Comment 1
2012-09-28 09:59:40 PDT
I'm not convinced that this is a worthwhile thing to do. Const is not really useful for optimization, because the qualifier can be dropped with const_cast at any time, and compiler must expect that. And extra visual noise does not improve readability. Const is useful to statically ensure correctness, which is not an issue for immutable objects like Localizer class instances. There are additional considerations why we don't use const in other cases (e.g. why we don't use "const Node&"), which are out of scope to discuss here.
yosin
Comment 2
2012-09-30 23:11:21 PDT
Making Localizer "const" may reduce below comments during review. Also for me, adding "const" improves readability. From review for
https://bugs.webkit.org/show_bug.cgi?id=97318
View in context:
https://bugs.webkit.org/attachment.cgi?id=165971&action=review
> Source/WebCore/html/shadow/DateTimeNumericFieldElement.h:75 > + Localizer& localizer() const;
Can the return value be const?
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug