Diff
Modified: trunk/Source/WTF/ChangeLog (222179 => 222180)
--- trunk/Source/WTF/ChangeLog 2017-09-18 21:03:31 UTC (rev 222179)
+++ trunk/Source/WTF/ChangeLog 2017-09-18 21:04:58 UTC (rev 222180)
@@ -1,3 +1,16 @@
+2017-09-18 Ryan Haddad <[email protected]>
+
+ Unreviewed, rolling out r222170.
+
+ The API test added with this change is failing.
+
+ Reverted changeset:
+
+ "Allow WTF::map to use any class that is iterable and has a
+ size getter"
+ https://bugs.webkit.org/show_bug.cgi?id=177026
+ http://trac.webkit.org/changeset/222170
+
2017-09-18 Youenn Fablet <[email protected]>
Allow WTF::map to use any class that is iterable and has a size getter
Modified: trunk/Source/WTF/wtf/Vector.h (222179 => 222180)
--- trunk/Source/WTF/wtf/Vector.h 2017-09-18 21:03:31 UTC (rev 222179)
+++ trunk/Source/WTF/wtf/Vector.h 2017-09-18 21:04:58 UTC (rev 222180)
@@ -1562,49 +1562,34 @@
return removeRepeatedElements(vector, [] (T& a, T& b) { return a == b; });
}
-template<typename MapFunction, typename SourceType>
-struct MapFunctionInspector {
+template<typename Transformer, typename SourceType> struct Mapper {
using RealSourceType = typename std::remove_reference<SourceType>::type;
- using IteratorType = decltype(std::begin(std::declval<RealSourceType>()));
- using SourceItemType = typename std::iterator_traits<IteratorType>::value_type;
-};
+ using SourceItemType = typename RealSourceType::ValueType;
+ using DestinationItemType = typename std::result_of<Transformer(SourceItemType&&)>::type;
-template<typename MapFunction, typename SourceType, typename Enable = void>
-struct Mapper {
- using SourceItemType = typename MapFunctionInspector<MapFunction, SourceType>::SourceItemType;
- using DestinationItemType = typename std::result_of<MapFunction(SourceItemType&)>::type;
-
- static Vector<DestinationItemType> map(SourceType source, const MapFunction& mapFunction)
+ static Vector<DestinationItemType> map(const RealSourceType& source, const Transformer& transformer)
{
Vector<DestinationItemType> result;
- // FIXME: Use std::size when available on all compilers.
result.reserveInitialCapacity(source.size());
for (auto& item : source)
- result.uncheckedAppend(mapFunction(item));
+ result.uncheckedAppend(transformer(item));
return result;
}
-};
-template<typename MapFunction, typename SourceType>
-struct Mapper<MapFunction, SourceType, typename std::enable_if<std::is_rvalue_reference<SourceType&&>::value>::type> {
- using SourceItemType = typename MapFunctionInspector<MapFunction, SourceType>::SourceItemType;
- using DestinationItemType = typename std::result_of<MapFunction(SourceItemType&&)>::type;
-
- static Vector<DestinationItemType> map(SourceType source, const MapFunction& mapFunction)
+ static Vector<DestinationItemType> map(RealSourceType&& source, const Transformer& transformer)
{
Vector<DestinationItemType> result;
- // FIXME: Use std::size when available on all compilers.
result.reserveInitialCapacity(source.size());
for (auto& item : source)
- result.uncheckedAppend(mapFunction(WTFMove(item)));
+ result.uncheckedAppend(transformer(std::forward<SourceItemType>(item)));
return result;
}
};
-template<typename MapFunction, typename SourceType>
-Vector<typename Mapper<MapFunction, SourceType>::DestinationItemType> map(SourceType&& source, MapFunction&& mapFunction)
+template<typename Transformer, typename VectorType>
+Vector<typename Mapper<Transformer, VectorType>::DestinationItemType> map(VectorType&& source, Transformer&& transformer)
{
- return Mapper<MapFunction, SourceType>::map(std::forward<SourceType>(source), std::forward<MapFunction>(mapFunction));
+ return Mapper<Transformer, VectorType>::map(std::forward<VectorType>(source), std::forward<Transformer>(transformer));
}
} // namespace WTF
Modified: trunk/Source/WebCore/ChangeLog (222179 => 222180)
--- trunk/Source/WebCore/ChangeLog 2017-09-18 21:03:31 UTC (rev 222179)
+++ trunk/Source/WebCore/ChangeLog 2017-09-18 21:04:58 UTC (rev 222180)
@@ -1,3 +1,16 @@
+2017-09-18 Ryan Haddad <[email protected]>
+
+ Unreviewed, rolling out r222170.
+
+ The API test added with this change is failing.
+
+ Reverted changeset:
+
+ "Allow WTF::map to use any class that is iterable and has a
+ size getter"
+ https://bugs.webkit.org/show_bug.cgi?id=177026
+ http://trac.webkit.org/changeset/222170
+
2017-09-18 Don Olmstead <[email protected]>
[Curl] Forward declare SSL context
Modified: trunk/Source/WebCore/loader/appcache/ApplicationCacheHost.cpp (222179 => 222180)
--- trunk/Source/WebCore/loader/appcache/ApplicationCacheHost.cpp 2017-09-18 21:03:31 UTC (rev 222179)
+++ trunk/Source/WebCore/loader/appcache/ApplicationCacheHost.cpp 2017-09-18 21:04:58 UTC (rev 222180)
@@ -327,11 +327,15 @@
Vector<ApplicationCacheHost::ResourceInfo> ApplicationCacheHost::resourceList()
{
+ Vector<ResourceInfo> result;
+
auto* cache = applicationCache();
if (!cache || !cache->isComplete())
- return { };
+ return result;
- return WTF::map(cache->resources(), [] (auto& urlAndResource) -> ApplicationCacheHost::ResourceInfo {
+ result.reserveInitialCapacity(cache->resources().size());
+
+ for (auto& urlAndResource : cache->resources()) {
ASSERT(urlAndResource.value);
auto& resource = *urlAndResource.value;
@@ -342,8 +346,10 @@
bool isForeign = type & ApplicationCacheResource::Foreign;
bool isFallback = type & ApplicationCacheResource::Fallback;
- return { resource.url(), isMaster, isManifest, isFallback, isForeign, isExplicit, resource.estimatedSizeInStorage() };
- });
+ result.uncheckedAppend({ resource.url(), isMaster, isManifest, isFallback, isForeign, isExplicit, resource.estimatedSizeInStorage() });
+ }
+
+ return result;
}
ApplicationCacheHost::CacheInfo ApplicationCacheHost::applicationCacheInfo()
Modified: trunk/Source/WebCore/page/DOMWindow.cpp (222179 => 222180)
--- trunk/Source/WebCore/page/DOMWindow.cpp 2017-09-18 21:03:31 UTC (rev 222179)
+++ trunk/Source/WebCore/page/DOMWindow.cpp 2017-09-18 21:04:58 UTC (rev 222180)
@@ -297,9 +297,10 @@
if (alreadyDispatched)
return;
- auto windows = WTF::map(set, [] (auto& keyValue) {
- return Ref<DOMWindow>(*(keyValue.key));
- });
+ Vector<Ref<DOMWindow>> windows;
+ windows.reserveInitialCapacity(set.size());
+ for (auto& keyValue : set)
+ windows.uncheckedAppend(*keyValue.key);
for (auto& window : windows) {
if (!set.contains(window.ptr()))
Modified: trunk/Tools/ChangeLog (222179 => 222180)
--- trunk/Tools/ChangeLog 2017-09-18 21:03:31 UTC (rev 222179)
+++ trunk/Tools/ChangeLog 2017-09-18 21:04:58 UTC (rev 222180)
@@ -1,3 +1,16 @@
+2017-09-18 Ryan Haddad <[email protected]>
+
+ Unreviewed, rolling out r222170.
+
+ The API test added with this change is failing.
+
+ Reverted changeset:
+
+ "Allow WTF::map to use any class that is iterable and has a
+ size getter"
+ https://bugs.webkit.org/show_bug.cgi?id=177026
+ http://trac.webkit.org/changeset/222170
+
2017-09-18 Myles C. Maxfield <[email protected]>
Add a section in WSL's documentation about how API objects and WSL interact
Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/Vector.cpp (222179 => 222180)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/Vector.cpp 2017-09-18 21:03:31 UTC (rev 222179)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/Vector.cpp 2017-09-18 21:04:58 UTC (rev 222180)
@@ -26,10 +26,8 @@
#include "config.h"
#include "MoveOnly.h"
-#include <wtf/HashMap.h>
#include <wtf/Vector.h>
-#include <wtf/text/StringHash.h>
-#include <wtf/text/WTFString.h>
+#include <wtf/text/CString.h>
namespace TestWebKitAPI {
@@ -728,51 +726,4 @@
EXPECT_EQ(5U, mapped[2].value());
}
-TEST(WTF_Vector, MapFromHashMap)
-{
- HashMap<String, String> map;
- map.set(String { "k1" }, String { "v1" });
- map.set(String { "k2" }, String { "v2" });
- map.set(String { "k3" }, String { "v3" });
-
- auto mapped = WTF::map(map, [&] (KeyValuePair<String, String>& pair) -> String {
- return pair.value;
- });
- std::sort(mapped.begin(), mapped.end(), WTF::codePointCompareLessThan);
-
- EXPECT_EQ(3U, mapped.size());
- EXPECT_TRUE(mapped[0] == "v1");
- EXPECT_TRUE(mapped[1] == "v2");
- EXPECT_TRUE(mapped[2] == "v3");
-
- mapped = WTF::map(map, [&] (const auto& pair) -> String {
- return pair.key;
- });
- std::sort(mapped.begin(), mapped.end(), WTF::codePointCompareLessThan);
-
- EXPECT_EQ(3U, mapped.size());
- EXPECT_TRUE(mapped[0] == "k1");
- EXPECT_TRUE(mapped[1] == "k2");
- EXPECT_TRUE(mapped[2] == "k3");
-
- mapped = WTF::map(WTFMove(map), [&] (KeyValuePair<String, String>&& pair) -> String {
- return WTFMove(pair.value);
- });
- std::sort(mapped.begin(), mapped.end(), WTF::codePointCompareLessThan);
-
- EXPECT_EQ(3U, mapped.size());
- EXPECT_TRUE(mapped[0] == "v1");
- EXPECT_TRUE(mapped[1] == "v2");
- EXPECT_TRUE(mapped[2] == "v3");
-
- EXPECT_TRUE(map.contains("k1"));
- EXPECT_TRUE(map.contains("k2"));
- EXPECT_TRUE(map.contains("k3"));
-
- EXPECT_TRUE(map.get("k1").isNull());
- EXPECT_TRUE(map.get("k2").isNull());
- EXPECT_TRUE(map.get("k3").isNull());
-
-}
-
} // namespace TestWebKitAPI