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
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.
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?