Improvements to Intl code
https://bugs.webkit.org/show_bug.cgi?id=154486

Reviewed by Darin Adler.

This patch does several things:
- Use std::unique_ptr to store ICU objects.
- Pass Vector::size() to ICU functions that take a buffer size instead
  of Vector::capacity().
- If U_SUCCESS(status) is true, it means there is no error, but there
  could be warnings. ICU functions ignore warnings. So, there is no need
  to reset status to U_ZERO_ERROR.
- Remove the initialization of the String instance variables of
  IntlDateTimeFormat. These values are never read and cause unnecessary
  memory allocation.
- Fix coding style.
- Some small optimization.

* runtime/IntlCollator.cpp:
(JSC::IntlCollator::UCollatorDeleter::operator()):
(JSC::IntlCollator::createCollator):
(JSC::IntlCollator::compareStrings):
(JSC::IntlCollator::~IntlCollator): Deleted.
* runtime/IntlCollator.h:
* runtime/IntlDateTimeFormat.cpp:
(JSC::IntlDateTimeFormat::UDateFormatDeleter::operator()):
(JSC::defaultTimeZone):
(JSC::canonicalizeTimeZoneName):
(JSC::toDateTimeOptionsAnyDate):
(JSC::IntlDateTimeFormat::initializeDateTimeFormat):
(JSC::IntlDateTimeFormat::weekdayString):
(JSC::IntlDateTimeFormat::format):
(JSC::IntlDateTimeFormat::~IntlDateTimeFormat): Deleted.
(JSC::localeData): Deleted.
* runtime/IntlDateTimeFormat.h:
* runtime/IntlDateTimeFormatConstructor.cpp:
* runtime/IntlNumberFormatConstructor.cpp:
* runtime/IntlObject.cpp:
(JSC::numberingSystemsForLocale):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@196887 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/runtime/IntlDateTimeFormat.h b/Source/JavaScriptCore/runtime/IntlDateTimeFormat.h
index 7dc57d0..a25c160 100644
--- a/Source/JavaScriptCore/runtime/IntlDateTimeFormat.h
+++ b/Source/JavaScriptCore/runtime/IntlDateTimeFormat.h
@@ -54,7 +54,6 @@
 
 protected:
     IntlDateTimeFormat(VM&, Structure*);
-    ~IntlDateTimeFormat();
     void finishCreation(VM&);
     static void destroy(JSCell*);
     static void visitChildren(JSCell*, SlotVisitor&);
@@ -70,6 +69,11 @@
     enum class Second { None, TwoDigit, Numeric };
     enum class TimeZoneName { None, Short, Long };
 
+    struct UDateFormatDeleter {
+        void operator()(UDateFormat*) const;
+    };
+
+    void setFormatsFromPattern(const StringView&);
     static const char* weekdayString(Weekday);
     static const char* eraString(Era);
     static const char* yearString(Year);
@@ -81,14 +85,13 @@
     static const char* timeZoneNameString(TimeZoneName);
 
     bool m_initializedDateTimeFormat { false };
-    void setFormatsFromPattern(const StringView&);
     WriteBarrier<JSBoundFunction> m_boundFormat;
-    UDateFormat* m_dateFormat { nullptr };
+    std::unique_ptr<UDateFormat, UDateFormatDeleter> m_dateFormat;
 
-    String m_locale { ASCIILiteral("en") };
-    String m_calendar { ASCIILiteral("gregorian") };
-    String m_numberingSystem { ASCIILiteral("latn") };
-    String m_timeZone { ASCIILiteral("UTC") };
+    String m_locale;
+    String m_calendar;
+    String m_numberingSystem;
+    String m_timeZone;
     bool m_hour12 { true };
     Weekday m_weekday { Weekday::None };
     Era m_era { Era::None };