Chromium Code Reviews| Index: chrome/browser/history/text_database.cc |
| diff --git a/chrome/browser/history/text_database.cc b/chrome/browser/history/text_database.cc |
| index bb70fc75f8e7e0996fcebf26b0e7069af5b51d43..e767cedb01b24149c7ddf281c560e2f1c28ce4eb 100644 |
| --- a/chrome/browser/history/text_database.cc |
| +++ b/chrome/browser/history/text_database.cc |
| @@ -12,6 +12,7 @@ |
| #include "base/logging.h" |
| #include "base/metrics/histogram.h" |
| #include "base/string_number_conversions.h" |
| +#include "base/string_piece.h" |
|
erikwright (departed)
2011/12/14 19:09:58
I guess we don't need this include at the moment.
|
| #include "base/stringprintf.h" |
| #include "base/utf_string_conversions.h" |
| #include "chrome/browser/diagnostics/sqlite_diagnostics.h" |
| @@ -111,9 +112,14 @@ TextDatabase::DBIdent TextDatabase::FileNameToID(const FilePath& file_path) { |
| return 0; |
| } |
| + // TODO: Once StringPiece supports a templated interface over the |
| + // underlying string type, use it here instead of substr, since that |
| + // will avoid needless string copies. StringPiece cannot be used |
| + // right now because FilePath::StringType could use either 8 or 16 bit |
| + // characters, depending on the OS. |
| int year, month; |
| - base::StringToInt(suffix.begin(), suffix.begin() + 4, &year); |
| - base::StringToInt(suffix.begin() + 5, suffix.begin() + 7, &month); |
| + base::StringToInt(suffix.substr(0, 4), &year); |
| + base::StringToInt(suffix.substr(5, 2), &month); |
| return year * 100 + month; |
| } |