summaryrefslogtreecommitdiff
blob: 0c5c20ea19d9cc9e392cc4747de3e4f7c7552627 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
From 7f1503a80edc5ccd73559b227a242eeb9c1bea93 Mon Sep 17 00:00:00 2001
From: Stephan Hartmann <stha09@googlemail.com>
Date: Mon, 30 Mar 2020 07:26:49 +0000
Subject: [PATCH] GCC: fix template specialization in WTF::VectorMover

GCC complains that explicit specialization in non-namespace scope
is happening for MoveOverlappingImpl. However, secialization is
not really necessary here with templates and can be moved
into MoveOverlappingImpl method without changing generated code.

Bug: 819294
Change-Id: I90b893b9701748302f7b900fbcc2c341685fe0d3
---

diff --git a/third_party/blink/renderer/platform/wtf/vector.h b/third_party/blink/renderer/platform/wtf/vector.h
index 632d308..82aaf96 100644
--- a/third_party/blink/renderer/platform/wtf/vector.h
+++ b/third_party/blink/renderer/platform/wtf/vector.h
@@ -205,30 +205,23 @@
     }
   }
 
-  template <bool = Allocator::kIsGarbageCollected>
-  static void MoveOverlappingImpl(const T* src, const T* src_end, T* dst);
-  template <>
-  static void MoveOverlappingImpl<false>(const T* src,
-                                         const T* src_end,
-                                         T* dst) {
-    memmove(dst, src,
-            reinterpret_cast<const char*>(src_end) -
-                reinterpret_cast<const char*>(src));
-  }
-  template <>
-  static void MoveOverlappingImpl<true>(const T* src,
-                                        const T* src_end,
-                                        T* dst) {
-    if (src == dst)
-      return;
-    if (dst < src) {
-      for (; src < src_end; ++src, ++dst)
-        AtomicWriteMemcpy<sizeof(T)>(dst, src);
+  static void MoveOverlappingImpl(const T* src, const T* src_end, T* dst) {
+    if (Allocator::kIsGarbageCollected) {
+      if (src == dst)
+        return;
+      if (dst < src) {
+        for (; src < src_end; ++src, ++dst)
+          AtomicWriteMemcpy<sizeof(T)>(dst, src);
+      } else {
+        --src_end;
+        T* dst_end = dst + (src_end - src);
+        for (; src_end >= src; --src_end, --dst_end)
+          AtomicWriteMemcpy<sizeof(T)>(dst_end, src_end);
+      }
     } else {
-      --src_end;
-      T* dst_end = dst + (src_end - src);
-      for (; src_end >= src; --src_end, --dst_end)
-        AtomicWriteMemcpy<sizeof(T)>(dst_end, src_end);
+      memmove(dst, src,
+              reinterpret_cast<const char*>(src_end) -
+                  reinterpret_cast<const char*>(src));
     }
   }