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

Side by Side Diff: third_party/WebKit/Source/wtf/text/StringStatics.cpp

Issue 1436153002: Apply clang-format with Chromium-style without column limit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2010 Apple Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 16 matching lines...) Expand all
27 #include "StringStatics.h" 27 #include "StringStatics.h"
28 28
29 #include "AtomicString.h" 29 #include "AtomicString.h"
30 #include "StringImpl.h" 30 #include "StringImpl.h"
31 #include "wtf/DynamicAnnotations.h" 31 #include "wtf/DynamicAnnotations.h"
32 #include "wtf/MainThread.h" 32 #include "wtf/MainThread.h"
33 #include "wtf/StaticConstructors.h" 33 #include "wtf/StaticConstructors.h"
34 34
35 namespace WTF { 35 namespace WTF {
36 36
37 StringImpl* StringImpl::empty() 37 StringImpl* StringImpl::empty() {
38 { 38 DEFINE_STATIC_LOCAL(StringImpl, emptyString, (ConstructEmptyString));
39 DEFINE_STATIC_LOCAL(StringImpl, emptyString, (ConstructEmptyString)); 39 WTF_ANNOTATE_BENIGN_RACE(&emptyString,
40 WTF_ANNOTATE_BENIGN_RACE(&emptyString, 40 "Benign race on the reference counter of a static str ing created by StringImpl::empty");
41 "Benign race on the reference counter of a static string created by Stri ngImpl::empty"); 41 return &emptyString;
42 return &emptyString;
43 } 42 }
44 43
45 StringImpl* StringImpl::empty16Bit() 44 StringImpl* StringImpl::empty16Bit() {
46 { 45 DEFINE_STATIC_LOCAL(StringImpl, emptyString, (ConstructEmptyString16Bit));
47 DEFINE_STATIC_LOCAL(StringImpl, emptyString, (ConstructEmptyString16Bit)); 46 WTF_ANNOTATE_BENIGN_RACE(&emptyString,
48 WTF_ANNOTATE_BENIGN_RACE(&emptyString, 47 "Benign race on the reference counter of a static str ing created by StringImpl::empty16Bit");
49 "Benign race on the reference counter of a static string created by Stri ngImpl::empty16Bit"); 48 return &emptyString;
50 return &emptyString;
51 } 49 }
52 50
53 WTF_EXPORT DEFINE_GLOBAL(AtomicString, nullAtom) 51 WTF_EXPORT DEFINE_GLOBAL(AtomicString, nullAtom)
54 WTF_EXPORT DEFINE_GLOBAL(AtomicString, emptyAtom) 52 WTF_EXPORT DEFINE_GLOBAL(AtomicString, emptyAtom)
55 WTF_EXPORT DEFINE_GLOBAL(AtomicString, starAtom) 53 WTF_EXPORT DEFINE_GLOBAL(AtomicString, starAtom)
56 WTF_EXPORT DEFINE_GLOBAL(AtomicString, xmlAtom) 54 WTF_EXPORT DEFINE_GLOBAL(AtomicString, xmlAtom)
57 WTF_EXPORT DEFINE_GLOBAL(AtomicString, xmlnsAtom) 55 WTF_EXPORT DEFINE_GLOBAL(AtomicString, xmlnsAtom)
58 WTF_EXPORT DEFINE_GLOBAL(AtomicString, xlinkAtom) 56 WTF_EXPORT DEFINE_GLOBAL(AtomicString, xlinkAtom)
59 57
60 // This is not an AtomicString because it is unlikely to be used as an 58 // This is not an AtomicString because it is unlikely to be used as an
61 // event/element/attribute name, so it shouldn't pollute the AtomicString hash 59 // event/element/attribute name, so it shouldn't pollute the AtomicString ha sh
62 // table. 60 // table.
63 WTF_EXPORT DEFINE_GLOBAL(String, xmlnsWithColon) 61 WTF_EXPORT DEFINE_GLOBAL(String, xmlnsWithColon)
64 62
65 NEVER_INLINE unsigned StringImpl::hashSlowCase() const 63 NEVER_INLINE unsigned StringImpl::hashSlowCase() const {
66 { 64 if (is8Bit())
67 if (is8Bit()) 65 setHash(StringHasher::computeHashAndMaskTop8Bits(characters8(), m_length));
68 setHash(StringHasher::computeHashAndMaskTop8Bits(characters8(), m_length )); 66 else
69 else 67 setHash(StringHasher::computeHashAndMaskTop8Bits(characters16(), m_length));
70 setHash(StringHasher::computeHashAndMaskTop8Bits(characters16(), m_lengt h)); 68 return existingHash();
71 return existingHash();
72 } 69 }
73 70
74 void AtomicString::init() 71 void AtomicString::init() {
75 { 72 ASSERT(isMainThread());
76 ASSERT(isMainThread());
77 73
78 new (NotNull, (void*)&nullAtom) AtomicString; 74 new (NotNull, (void*)&nullAtom) AtomicString;
79 new (NotNull, (void*)&emptyAtom) AtomicString(""); 75 new (NotNull, (void*)&emptyAtom) AtomicString("");
80 } 76 }
81 77
82 template<unsigned charactersCount> 78 template <unsigned charactersCount>
83 PassRefPtr<StringImpl> addStaticASCIILiteral(const char (&characters)[characters Count]) 79 PassRefPtr<StringImpl> addStaticASCIILiteral(const char(&characters)[charactersC ount]) {
84 { 80 unsigned length = charactersCount - 1;
85 unsigned length = charactersCount - 1; 81 unsigned hash = StringHasher::computeHashAndMaskTop8Bits(reinterpret_cast<cons t LChar*>(characters), length);
86 unsigned hash = StringHasher::computeHashAndMaskTop8Bits(reinterpret_cast<co nst LChar*>(characters), length); 82 return adoptRef(StringImpl::createStatic(characters, length, hash));
87 return adoptRef(StringImpl::createStatic(characters, length, hash));
88 } 83 }
89 84
90 void StringStatics::init() 85 void StringStatics::init() {
91 { 86 ASSERT(isMainThread());
92 ASSERT(isMainThread());
93 87
94 // FIXME: These should be allocated at compile time. 88 // FIXME: These should be allocated at compile time.
95 new (NotNull, (void*)&starAtom) AtomicString("*", AtomicString::ConstructFro mLiteral); 89 new (NotNull, (void*)&starAtom) AtomicString("*", AtomicString::ConstructFromL iteral);
96 new (NotNull, (void*)&xmlAtom) AtomicString(addStaticASCIILiteral("xml")); 90 new (NotNull, (void*)&xmlAtom) AtomicString(addStaticASCIILiteral("xml"));
97 new (NotNull, (void*)&xmlnsAtom) AtomicString(addStaticASCIILiteral("xmlns") ); 91 new (NotNull, (void*)&xmlnsAtom) AtomicString(addStaticASCIILiteral("xmlns"));
98 new (NotNull, (void*)&xlinkAtom) AtomicString(addStaticASCIILiteral("xlink") ); 92 new (NotNull, (void*)&xlinkAtom) AtomicString(addStaticASCIILiteral("xlink"));
99 new (NotNull, (void*)&xmlnsWithColon) String("xmlns:"); 93 new (NotNull, (void*)&xmlnsWithColon) String("xmlns:");
100 } 94 }
101
102 } 95 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringStatics.h ('k') | third_party/WebKit/Source/wtf/text/StringUTF8Adaptor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698