Title: [141917] trunk
- Revision
- 141917
- Author
- [email protected]
- Date
- 2013-02-05 12:49:20 -0800 (Tue, 05 Feb 2013)
Log Message
Source/WTF: Make StringBuilder::toAtomicString() consistent with StringBuilder::toString() for strings of length zero
https://bugs.webkit.org/show_bug.cgi?id=108894
Patch by Benjamin Poulain <[email protected]> on 2013-02-05
Reviewed by Andreas Kling.
* wtf/text/StringBuilder.h:
(WTF::StringBuilder::toAtomicString): The function was returning the nullAtom for strings of length zero.
This is inconsistent with StringBuilder::toString() which always return an empty string.
This patch unifies the behavior.
Tools: Make StringBuilder::toAtomicString() consistent with StringBuilder::toString() for strings of null length
https://bugs.webkit.org/show_bug.cgi?id=108894
Patch by Benjamin Poulain <[email protected]> on 2013-02-05
Reviewed by Andreas Kling.
* TestWebKitAPI/Tests/WTF/StringBuilder.cpp:
Extend the tests to check toAtomicString() on an empty builder.
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (141916 => 141917)
--- trunk/Source/WTF/ChangeLog 2013-02-05 20:43:27 UTC (rev 141916)
+++ trunk/Source/WTF/ChangeLog 2013-02-05 20:49:20 UTC (rev 141917)
@@ -1,3 +1,16 @@
+2013-02-05 Benjamin Poulain <[email protected]>
+
+ Make StringBuilder::toAtomicString() consistent with StringBuilder::toString() for strings of length zero
+ https://bugs.webkit.org/show_bug.cgi?id=108894
+
+ Reviewed by Andreas Kling.
+
+ * wtf/text/StringBuilder.h:
+ (WTF::StringBuilder::toAtomicString): The function was returning the nullAtom for strings of length zero.
+ This is inconsistent with StringBuilder::toString() which always return an empty string.
+
+ This patch unifies the behavior.
+
2013-02-04 Mark Hahnenberg <[email protected]>
Structure::m_outOfLineCapacity is unnecessary
Modified: trunk/Source/WTF/wtf/text/StringBuilder.h (141916 => 141917)
--- trunk/Source/WTF/wtf/text/StringBuilder.h 2013-02-05 20:43:27 UTC (rev 141916)
+++ trunk/Source/WTF/wtf/text/StringBuilder.h 2013-02-05 20:49:20 UTC (rev 141917)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009, 2010, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
* Copyright (C) 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -179,7 +179,7 @@
AtomicString toAtomicString() const
{
if (!m_length)
- return AtomicString();
+ return emptyAtom;
// If the buffer is sufficiently over-allocated, make a new AtomicString from a copy so its buffer is not so large.
if (canShrink()) {
Modified: trunk/Tools/ChangeLog (141916 => 141917)
--- trunk/Tools/ChangeLog 2013-02-05 20:43:27 UTC (rev 141916)
+++ trunk/Tools/ChangeLog 2013-02-05 20:49:20 UTC (rev 141917)
@@ -1,3 +1,13 @@
+2013-02-05 Benjamin Poulain <[email protected]>
+
+ Make StringBuilder::toAtomicString() consistent with StringBuilder::toString() for strings of null length
+ https://bugs.webkit.org/show_bug.cgi?id=108894
+
+ Reviewed by Andreas Kling.
+
+ * TestWebKitAPI/Tests/WTF/StringBuilder.cpp:
+ Extend the tests to check toAtomicString() on an empty builder.
+
2013-02-05 Jochen Eisinger <[email protected]>
[chromium] remove methods from the WebTestRunner interface that are only used by WebTestProxyBase
Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/StringBuilder.cpp (141916 => 141917)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/StringBuilder.cpp 2013-02-05 20:43:27 UTC (rev 141916)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/StringBuilder.cpp 2013-02-05 20:49:20 UTC (rev 141917)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -284,4 +285,51 @@
ASSERT_EQ(atomicString2.impl(), string.impl());
}
+TEST(StringBuilderTest, ToAtomicStringOnEmpty)
+{
+ { // Default constructed.
+ StringBuilder builder;
+ AtomicString atomicString = builder.toAtomicString();
+ ASSERT_EQ(emptyAtom, atomicString);
+ }
+ { // With capacity.
+ StringBuilder builder;
+ builder.reserveCapacity(64);
+ AtomicString atomicString = builder.toAtomicString();
+ ASSERT_EQ(emptyAtom, atomicString);
+ }
+ { // AtomicString constructed from a null string.
+ StringBuilder builder;
+ builder.append(String());
+ AtomicString atomicString = builder.toAtomicString();
+ ASSERT_EQ(emptyAtom, atomicString);
+ }
+ { // AtomicString constructed from an empty string.
+ StringBuilder builder;
+ builder.append(emptyString());
+ AtomicString atomicString = builder.toAtomicString();
+ ASSERT_EQ(emptyAtom, atomicString);
+ }
+ { // AtomicString constructed from an empty StringBuilder.
+ StringBuilder builder;
+ StringBuilder emptyBuilder;
+ builder.append(emptyBuilder);
+ AtomicString atomicString = builder.toAtomicString();
+ ASSERT_EQ(emptyAtom, atomicString);
+ }
+ { // AtomicString constructed from an empty char* string.
+ StringBuilder builder;
+ builder.append("", 0);
+ AtomicString atomicString = builder.toAtomicString();
+ ASSERT_EQ(emptyAtom, atomicString);
+ }
+ { // Cleared StringBuilder.
+ StringBuilder builder;
+ builder.appendLiteral("WebKit");
+ builder.clear();
+ AtomicString atomicString = builder.toAtomicString();
+ ASSERT_EQ(emptyAtom, atomicString);
+ }
+}
+
} // namespace
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes