Title: [203119] trunk
- Revision
- 203119
- Author
- mmaxfi...@apple.com
- Date
- 2016-07-12 11:48:04 -0700 (Tue, 12 Jul 2016)
Log Message
Relax ordering requirements on StringView::CodePoints iterator
https://bugs.webkit.org/show_bug.cgi?id=159609
Reviewed by Darin Adler.
Source/WTF:
Previously, there was a requirement where if you use a CodePoints
iterator, you couldn't dereference twice in a row or increment
twice in a row. This restriction is unnecessary.
* wtf/text/StringView.h:
(WTF::StringView::CodePoints::Iterator::Iterator):
(WTF::StringView::CodePoints::Iterator::advanceCurrentCodePoint):
(WTF::StringView::CodePoints::Iterator::operator*):
(WTF::StringView::CodePoints::Iterator::operator==):
Tools:
* TestWebKitAPI/Tests/WTF/StringView.cpp:
(TestWebKitAPI::TEST):
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (203118 => 203119)
--- trunk/Source/WTF/ChangeLog 2016-07-12 17:43:28 UTC (rev 203118)
+++ trunk/Source/WTF/ChangeLog 2016-07-12 18:48:04 UTC (rev 203119)
@@ -1,3 +1,20 @@
+2016-07-12 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ Relax ordering requirements on StringView::CodePoints iterator
+ https://bugs.webkit.org/show_bug.cgi?id=159609
+
+ Reviewed by Darin Adler.
+
+ Previously, there was a requirement where if you use a CodePoints
+ iterator, you couldn't dereference twice in a row or increment
+ twice in a row. This restriction is unnecessary.
+
+ * wtf/text/StringView.h:
+ (WTF::StringView::CodePoints::Iterator::Iterator):
+ (WTF::StringView::CodePoints::Iterator::advanceCurrentCodePoint):
+ (WTF::StringView::CodePoints::Iterator::operator*):
+ (WTF::StringView::CodePoints::Iterator::operator==):
+
2016-07-12 Csaba Osztrogonác <o...@webkit.org>
JSCOnly bulidfix after r203078
Modified: trunk/Source/WTF/wtf/text/StringView.h (203118 => 203119)
--- trunk/Source/WTF/wtf/text/StringView.h 2016-07-12 17:43:28 UTC (rev 203118)
+++ trunk/Source/WTF/wtf/text/StringView.h 2016-07-12 18:48:04 UTC (rev 203119)
@@ -654,10 +654,9 @@
private:
const StringView& m_stringView;
- mutable unsigned m_index;
-#if !ASSERT_DISABLED
- mutable bool m_alreadyIncremented { false };
-#endif
+ unsigned m_index;
+ unsigned m_indexEnd;
+ UChar32 m_codePoint;
};
class StringView::CodeUnits::Iterator {
@@ -713,37 +712,35 @@
inline StringView::CodePoints::Iterator::Iterator(const StringView& stringView, unsigned index)
: m_stringView(stringView)
, m_index(index)
+ , m_indexEnd(index)
{
+ operator++();
}
inline auto StringView::CodePoints::Iterator::operator++() -> Iterator&
{
-#if !ASSERT_DISABLED
- ASSERT(m_alreadyIncremented);
- m_alreadyIncremented = false;
-#endif
+ ASSERT(m_indexEnd <= m_stringView.length());
+ m_index = m_indexEnd;
+ if (m_indexEnd == m_stringView.length()) {
+ m_codePoint = 0;
+ return *this;
+ }
+ if (m_stringView.is8Bit())
+ m_codePoint = m_stringView.characters8()[m_indexEnd++];
+ else
+ U16_NEXT(m_stringView.characters16(), m_indexEnd, m_stringView.length(), m_codePoint);
return *this;
}
inline UChar32 StringView::CodePoints::Iterator::operator*() const
{
-#if !ASSERT_DISABLED
- ASSERT(!m_alreadyIncremented);
- m_alreadyIncremented = true;
-#endif
-
- if (m_stringView.is8Bit())
- return m_stringView.characters8()[m_index++];
-
- UChar32 codePoint;
- U16_NEXT(m_stringView.characters16(), m_index, m_stringView.length(), codePoint);
- return codePoint;
+ ASSERT(m_indexEnd <= m_stringView.length());
+ return m_codePoint;
}
inline bool StringView::CodePoints::Iterator::operator==(const Iterator& other) const
{
ASSERT(&m_stringView == &other.m_stringView);
- ASSERT(!m_alreadyIncremented);
return m_index == other.m_index;
}
Modified: trunk/Tools/ChangeLog (203118 => 203119)
--- trunk/Tools/ChangeLog 2016-07-12 17:43:28 UTC (rev 203118)
+++ trunk/Tools/ChangeLog 2016-07-12 18:48:04 UTC (rev 203119)
@@ -1,3 +1,13 @@
+2016-07-12 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ Relax ordering requirements on StringView::CodePoints iterator
+ https://bugs.webkit.org/show_bug.cgi?id=159609
+
+ Reviewed by Darin Adler.
+
+ * TestWebKitAPI/Tests/WTF/StringView.cpp:
+ (TestWebKitAPI::TEST):
+
2016-07-12 Youenn Fablet <you...@apple.com>
Fixing Tools/Scripts/run-builtins-generator-tests after https://trac.webkit.org/changeset/202975
Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/StringView.cpp (203118 => 203119)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/StringView.cpp 2016-07-12 17:43:28 UTC (rev 203118)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/StringView.cpp 2016-07-12 18:48:04 UTC (rev 203119)
@@ -122,6 +122,13 @@
String helo("helo");
StringView heloView(helo);
+ auto codePointsIterator = heloView.codeUnits().begin();
+ EXPECT_EQ(*codePointsIterator, 'h');
+ EXPECT_EQ(*codePointsIterator, 'h');
+ ++codePointsIterator;
+ ++codePointsIterator;
+ EXPECT_EQ(*codePointsIterator, 'l');
+
EXPECT_TRUE(compareLoopIterations(heloView.codePoints(), {'h', 'e', 'l', 'o'}));
EXPECT_TRUE(compareLoopIterations(heloView.codeUnits(), {'h', 'e', 'l', 'o'}));
EXPECT_TRUE(compareLoopIterations(heloView.graphemeClusters(), {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes