summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-25 20:28:13 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-25 20:28:13 +0000
commit1414e78b8f508ab6fe1eab84ced8bdbdb3c1e667 (patch)
tree9092814bc1969fc3f7624bcbccfce522405b3e54 /base
parentd3afcdab089f7801ae151640ca11c9257ef2cd0f (diff)
downloadchromium_src-1414e78b8f508ab6fe1eab84ced8bdbdb3c1e667.zip
chromium_src-1414e78b8f508ab6fe1eab84ced8bdbdb3c1e667.tar.gz
chromium_src-1414e78b8f508ab6fe1eab84ced8bdbdb3c1e667.tar.bz2
base/i18n: Pass |str| as const reference in BreakIterator::Init().
BUG=None TEST=out/Debug/base_unittests --gtest_filter=BreakIteratorTest.* R=tsepez@chromium.org,evan@chromium.org Review URL: http://codereview.chromium.org/7008005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86689 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/i18n/break_iterator.cc6
-rw-r--r--base/i18n/break_iterator.h4
-rw-r--r--base/i18n/break_iterator_unittest.cc28
3 files changed, 19 insertions, 19 deletions
diff --git a/base/i18n/break_iterator.cc b/base/i18n/break_iterator.cc
index 118600a..224bb51 100644
--- a/base/i18n/break_iterator.cc
+++ b/base/i18n/break_iterator.cc
@@ -14,7 +14,7 @@ namespace i18n {
const size_t npos = -1;
-BreakIterator::BreakIterator(const string16* str, BreakType break_type)
+BreakIterator::BreakIterator(const string16& str, BreakType break_type)
: iter_(NULL),
string_(str),
break_type_(break_type),
@@ -43,7 +43,7 @@ bool BreakIterator::Init() {
return false;
}
iter_ = ubrk_open(break_type, NULL,
- string_->data(), static_cast<int32_t>(string_->size()),
+ string_.data(), static_cast<int32_t>(string_.size()),
&status);
if (U_FAILURE(status)) {
NOTREACHED() << "ubrk_open failed";
@@ -96,7 +96,7 @@ bool BreakIterator::IsWord() const {
string16 BreakIterator::GetString() const {
DCHECK(prev_ != npos && pos_ != npos);
- return string_->substr(prev_, pos_ - prev_);
+ return string_.substr(prev_, pos_ - prev_);
}
} // namespace i18n
diff --git a/base/i18n/break_iterator.h b/base/i18n/break_iterator.h
index acd5c30..82e8092 100644
--- a/base/i18n/break_iterator.h
+++ b/base/i18n/break_iterator.h
@@ -67,7 +67,7 @@ class BreakIterator {
};
// Requires |str| to live as long as the BreakIterator does.
- BreakIterator(const string16* str, BreakType break_type);
+ BreakIterator(const string16& str, BreakType break_type);
~BreakIterator();
// Init() must be called before any of the iterators are valid.
@@ -106,7 +106,7 @@ class BreakIterator {
void* iter_;
// The string we're iterating over.
- const string16* string_;
+ const string16& string_;
// The breaking style (word/space/newline).
BreakType break_type_;
diff --git a/base/i18n/break_iterator_unittest.cc b/base/i18n/break_iterator_unittest.cc
index bc0cca3..c1e521c 100644
--- a/base/i18n/break_iterator_unittest.cc
+++ b/base/i18n/break_iterator_unittest.cc
@@ -14,7 +14,7 @@ namespace i18n {
TEST(BreakIteratorTest, BreakWordEmpty) {
string16 empty;
- BreakIterator iter(&empty, BreakIterator::BREAK_WORD);
+ BreakIterator iter(empty, BreakIterator::BREAK_WORD);
ASSERT_TRUE(iter.Init());
EXPECT_FALSE(iter.Advance());
EXPECT_FALSE(iter.IsWord());
@@ -25,7 +25,7 @@ TEST(BreakIteratorTest, BreakWordEmpty) {
TEST(BreakIteratorTest, BreakWord) {
string16 space(UTF8ToUTF16(" "));
string16 str(UTF8ToUTF16(" foo bar! \npouet boom"));
- BreakIterator iter(&str, BreakIterator::BREAK_WORD);
+ BreakIterator iter(str, BreakIterator::BREAK_WORD);
ASSERT_TRUE(iter.Init());
EXPECT_TRUE(iter.Advance());
EXPECT_FALSE(iter.IsWord());
@@ -70,7 +70,7 @@ TEST(BreakIteratorTest, BreakWide16) {
L"\x03bf\x03c2\x0020\x0399\x03c3\x03c4\x03cc\x03c2"));
const string16 word1(str.substr(0, 10));
const string16 word2(str.substr(11, 5));
- BreakIterator iter(&str, BreakIterator::BREAK_WORD);
+ BreakIterator iter(str, BreakIterator::BREAK_WORD);
ASSERT_TRUE(iter.Init());
EXPECT_TRUE(iter.Advance());
EXPECT_TRUE(iter.IsWord());
@@ -94,7 +94,7 @@ TEST(BreakIteratorTest, BreakWide32) {
UTF8ToUTF16(base::StringPrintf("%s a", very_wide_char)));
const string16 very_wide_word(str.substr(0, 2));
- BreakIterator iter(&str, BreakIterator::BREAK_WORD);
+ BreakIterator iter(str, BreakIterator::BREAK_WORD);
ASSERT_TRUE(iter.Init());
EXPECT_TRUE(iter.Advance());
EXPECT_TRUE(iter.IsWord());
@@ -113,7 +113,7 @@ TEST(BreakIteratorTest, BreakWide32) {
TEST(BreakIteratorTest, BreakSpaceEmpty) {
string16 empty;
- BreakIterator iter(&empty, BreakIterator::BREAK_SPACE);
+ BreakIterator iter(empty, BreakIterator::BREAK_SPACE);
ASSERT_TRUE(iter.Init());
EXPECT_FALSE(iter.Advance());
EXPECT_FALSE(iter.IsWord());
@@ -123,7 +123,7 @@ TEST(BreakIteratorTest, BreakSpaceEmpty) {
TEST(BreakIteratorTest, BreakSpace) {
string16 str(UTF8ToUTF16(" foo bar! \npouet boom"));
- BreakIterator iter(&str, BreakIterator::BREAK_SPACE);
+ BreakIterator iter(str, BreakIterator::BREAK_SPACE);
ASSERT_TRUE(iter.Init());
EXPECT_TRUE(iter.Advance());
EXPECT_FALSE(iter.IsWord());
@@ -148,7 +148,7 @@ TEST(BreakIteratorTest, BreakSpace) {
TEST(BreakIteratorTest, BreakSpaceSP) {
string16 str(UTF8ToUTF16(" foo bar! \npouet boom "));
- BreakIterator iter(&str, BreakIterator::BREAK_SPACE);
+ BreakIterator iter(str, BreakIterator::BREAK_SPACE);
ASSERT_TRUE(iter.Init());
EXPECT_TRUE(iter.Advance());
EXPECT_FALSE(iter.IsWord());
@@ -178,7 +178,7 @@ TEST(BreakIteratorTest, BreakSpacekWide16) {
L"\x03bf\x03c2\x0020\x0399\x03c3\x03c4\x03cc\x03c2"));
const string16 word1(str.substr(0, 11));
const string16 word2(str.substr(11, 5));
- BreakIterator iter(&str, BreakIterator::BREAK_SPACE);
+ BreakIterator iter(str, BreakIterator::BREAK_SPACE);
ASSERT_TRUE(iter.Init());
EXPECT_TRUE(iter.Advance());
EXPECT_FALSE(iter.IsWord());
@@ -199,7 +199,7 @@ TEST(BreakIteratorTest, BreakSpaceWide32) {
UTF8ToUTF16(base::StringPrintf("%s a", very_wide_char)));
const string16 very_wide_word(str.substr(0, 3));
- BreakIterator iter(&str, BreakIterator::BREAK_SPACE);
+ BreakIterator iter(str, BreakIterator::BREAK_SPACE);
ASSERT_TRUE(iter.Init());
EXPECT_TRUE(iter.Advance());
EXPECT_FALSE(iter.IsWord());
@@ -215,7 +215,7 @@ TEST(BreakIteratorTest, BreakSpaceWide32) {
TEST(BreakIteratorTest, BreakLineEmpty) {
string16 empty;
- BreakIterator iter(&empty, BreakIterator::BREAK_NEWLINE);
+ BreakIterator iter(empty, BreakIterator::BREAK_NEWLINE);
ASSERT_TRUE(iter.Init());
EXPECT_FALSE(iter.Advance());
EXPECT_FALSE(iter.IsWord());
@@ -226,7 +226,7 @@ TEST(BreakIteratorTest, BreakLineEmpty) {
TEST(BreakIteratorTest, BreakLine) {
string16 nl(UTF8ToUTF16("\n"));
string16 str(UTF8ToUTF16("\nfoo bar!\n\npouet boom"));
- BreakIterator iter(&str, BreakIterator::BREAK_NEWLINE);
+ BreakIterator iter(str, BreakIterator::BREAK_NEWLINE);
ASSERT_TRUE(iter.Init());
EXPECT_TRUE(iter.Advance());
EXPECT_FALSE(iter.IsWord());
@@ -249,7 +249,7 @@ TEST(BreakIteratorTest, BreakLine) {
TEST(BreakIteratorTest, BreakLineNL) {
string16 nl(UTF8ToUTF16("\n"));
string16 str(UTF8ToUTF16("\nfoo bar!\n\npouet boom\n"));
- BreakIterator iter(&str, BreakIterator::BREAK_NEWLINE);
+ BreakIterator iter(str, BreakIterator::BREAK_NEWLINE);
ASSERT_TRUE(iter.Init());
EXPECT_TRUE(iter.Advance());
EXPECT_FALSE(iter.IsWord());
@@ -276,7 +276,7 @@ TEST(BreakIteratorTest, BreakLineWide16) {
L"\x03bf\x03c2\x000a\x0399\x03c3\x03c4\x03cc\x03c2"));
const string16 line1(str.substr(0, 11));
const string16 line2(str.substr(11, 5));
- BreakIterator iter(&str, BreakIterator::BREAK_NEWLINE);
+ BreakIterator iter(str, BreakIterator::BREAK_NEWLINE);
ASSERT_TRUE(iter.Init());
EXPECT_TRUE(iter.Advance());
EXPECT_FALSE(iter.IsWord());
@@ -296,7 +296,7 @@ TEST(BreakIteratorTest, BreakLineWide32) {
const string16 str(
UTF8ToUTF16(base::StringPrintf("%s\na", very_wide_char)));
const string16 very_wide_line(str.substr(0, 3));
- BreakIterator iter(&str, BreakIterator::BREAK_NEWLINE);
+ BreakIterator iter(str, BreakIterator::BREAK_NEWLINE);
ASSERT_TRUE(iter.Init());
EXPECT_TRUE(iter.Advance());
EXPECT_FALSE(iter.IsWord());