Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Unified Diff: chrome/browser/autofill/phone_number_i18n.h

Issue 7044102: Another performance improvement for phone library - at least +25% to previous cl (982ms for 100 i... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/autofill/phone_number_i18n.h
===================================================================
--- chrome/browser/autofill/phone_number_i18n.h (revision 89739)
+++ chrome/browser/autofill/phone_number_i18n.h (working copy)
@@ -10,10 +10,16 @@
#include <vector>
#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
#include "base/string16.h"
+namespace i18n {
+namespace phonenumbers {
+class PhoneNumber;
+}
+}
+
// Utilities to process, normalize and compare international phone numbers.
-
namespace autofill_i18n {
// Most of the following functions require |locale| to operate. The |locale| is
@@ -88,6 +94,37 @@
const string16& number_b,
const std::string& country_code);
+// The cached phone number, does parsing only once, improves performance.
+class PhoneObject {
+ public:
+ PhoneObject(const string16& number, const std::string& locale);
+ PhoneObject(const PhoneObject&);
+ PhoneObject();
+ ~PhoneObject();
+
+ string16 GetCountryCode() const;
+ string16 GetCityCode() const;
+ string16 GetNumber() const;
+ std::string GetLocale() const { return locale_; }
+
+ string16 GetWholeNumber() const;
+
+ PhoneMatch ComparePhones(const string16& phone) const;
+ PhoneMatch ComparePhones(const PhoneObject& phone) const;
Ilya Sherman 2011/06/21 00:31:26 nit: Are there any clients for the second version
GeorgeY 2011/06/21 23:24:44 Not, after recent changes - removed
+
+ PhoneObject& operator=(const PhoneObject& other);
+
+ bool ValidNumber() const { return i18n_number_ != NULL; }
+
+ private:
+ string16 city_code_;
+ string16 country_code_;
+ string16 number_;
+ mutable string16 whole_number_; // Set on first request.
+ std::string locale_;
+ scoped_ptr<i18n::phonenumbers::PhoneNumber> i18n_number_;
+};
+
} // namespace autofill_i18n
#endif // CHROME_BROWSER_AUTOFILL_PHONE_NUMBER_I18N_H_

Powered by Google App Engine
This is Rietveld 408576698