Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: Source/wtf/text/AtomicString.h

Issue 354023003: Add move constructor and assignment operator to RefPtr class (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Take Nico's feedback into consideration Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« Source/wtf/RefPtr.h ('K') | « Source/wtf/RefPtr.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } 62 }
63 63
64 template<unsigned charactersCount> 64 template<unsigned charactersCount>
65 ALWAYS_INLINE AtomicString(const char (&characters)[charactersCount], Constr uctFromLiteralTag) 65 ALWAYS_INLINE AtomicString(const char (&characters)[charactersCount], Constr uctFromLiteralTag)
66 : m_string(addFromLiteralData(characters, charactersCount - 1)) 66 : m_string(addFromLiteralData(characters, charactersCount - 1))
67 { 67 {
68 COMPILE_ASSERT(charactersCount > 1, AtomicStringFromLiteralNotEmpty); 68 COMPILE_ASSERT(charactersCount > 1, AtomicStringFromLiteralNotEmpty);
69 COMPILE_ASSERT((charactersCount - 1 <= ((unsigned(~0) - sizeof(StringImp l)) / sizeof(LChar))), AtomicStringFromLiteralCannotOverflow); 69 COMPILE_ASSERT((charactersCount - 1 <= ((unsigned(~0) - sizeof(StringImp l)) / sizeof(LChar))), AtomicStringFromLiteralCannotOverflow);
70 } 70 }
71 71
72 #if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
73 // We have to declare the copy constructor and copy assignment operator as w ell, otherwise
74 // they'll be implicitly deleted by adding the move constructor and move ass ignment operator.
75 // FIXME: Instead of explicitly casting to String&& here, we should use std: :move, but that requires us to
76 // have a standard library that supports move semantics.
77 AtomicString(const AtomicString& other) : m_string(other.m_string) { }
78 AtomicString(AtomicString&& other) : m_string(static_cast<String&&>(other.m_ string)) { }
79 AtomicString& operator=(const AtomicString& other) { m_string = other.m_stri ng; return *this; }
80 AtomicString& operator=(AtomicString&& other) { m_string = static_cast<Strin g&&>(other.m_string); return *this; }
81 #endif
82
83 // Hash table deleted values, which are only constructed and never copied or destroyed. 72 // Hash table deleted values, which are only constructed and never copied or destroyed.
84 AtomicString(WTF::HashTableDeletedValueType) : m_string(WTF::HashTableDelete dValue) { } 73 AtomicString(WTF::HashTableDeletedValueType) : m_string(WTF::HashTableDelete dValue) { }
85 bool isHashTableDeletedValue() const { return m_string.isHashTableDeletedVal ue(); } 74 bool isHashTableDeletedValue() const { return m_string.isHashTableDeletedVal ue(); }
86 75
87 static StringImpl* find(const StringImpl*); 76 static StringImpl* find(const StringImpl*);
88 77
89 operator const String&() const { return m_string; } 78 operator const String&() const { return m_string; }
90 const String& string() const { return m_string; }; 79 const String& string() const { return m_string; };
91 80
92 StringImpl* impl() const { return m_string.impl(); } 81 StringImpl* impl() const { return m_string.impl(); }
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 using WTF::nullAtom; 253 using WTF::nullAtom;
265 using WTF::emptyAtom; 254 using WTF::emptyAtom;
266 using WTF::starAtom; 255 using WTF::starAtom;
267 using WTF::xmlAtom; 256 using WTF::xmlAtom;
268 using WTF::xmlnsAtom; 257 using WTF::xmlnsAtom;
269 using WTF::xlinkAtom; 258 using WTF::xlinkAtom;
270 #endif 259 #endif
271 260
272 #include "wtf/text/StringConcatenate.h" 261 #include "wtf/text/StringConcatenate.h"
273 #endif // AtomicString_h 262 #endif // AtomicString_h
OLDNEW
« Source/wtf/RefPtr.h ('K') | « Source/wtf/RefPtr.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698