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

Side by Side Diff: third_party/WebKit/Source/wtf/BitArray.h

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
« no previous file with comments | « third_party/WebKit/Source/wtf/Atomics.h ('k') | third_party/WebKit/Source/wtf/BitVector.h » ('j') | 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) 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2012 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 13 matching lines...) Expand all
24 */ 24 */
25 25
26 #ifndef BitArray_h 26 #ifndef BitArray_h
27 #define BitArray_h 27 #define BitArray_h
28 28
29 #include "wtf/Assertions.h" 29 #include "wtf/Assertions.h"
30 #include <string.h> 30 #include <string.h>
31 31
32 namespace WTF { 32 namespace WTF {
33 33
34 template<unsigned arraySize> 34 template <unsigned arraySize>
35 class BitArray { 35 class BitArray {
36 public: 36 public:
37 BitArray(bool value = false) 37 BitArray(bool value = false) {
38 { 38 memset(m_data, value ? 0xFF : 0, sizeof(m_data));
39 memset(m_data, value ? 0xFF : 0, sizeof(m_data)); 39 }
40 }
41 40
42 void set(unsigned index) 41 void set(unsigned index) {
43 { 42 ASSERT_WITH_SECURITY_IMPLICATION(index < arraySize);
44 ASSERT_WITH_SECURITY_IMPLICATION(index < arraySize); 43 m_data[index / 8] |= 1 << (index & 7);
45 m_data[index / 8] |= 1 << (index & 7); 44 }
46 }
47 45
48 void clear(unsigned index) 46 void clear(unsigned index) {
49 { 47 ASSERT_WITH_SECURITY_IMPLICATION(index < arraySize);
50 ASSERT_WITH_SECURITY_IMPLICATION(index < arraySize); 48 m_data[index / 8] &= ~(1 << (index & 7));
51 m_data[index / 8] &= ~(1 << (index & 7)); 49 }
52 }
53 50
54 bool get(unsigned index) const 51 bool get(unsigned index) const {
55 { 52 ASSERT_WITH_SECURITY_IMPLICATION(index < arraySize);
56 ASSERT_WITH_SECURITY_IMPLICATION(index < arraySize); 53 return !!(m_data[index / 8] & (1 << (index & 7)));
57 return !!(m_data[index / 8] & (1 << (index & 7))); 54 }
58 }
59 55
60 private: 56 private:
61 unsigned char m_data[arraySize / 8 + 1]; 57 unsigned char m_data[arraySize / 8 + 1];
62 }; 58 };
63 59
64 } // namespace WTF 60 } // namespace WTF
65 61
66 using WTF::BitArray; 62 using WTF::BitArray;
67 63
68 #endif // BitArray_h 64 #endif // BitArray_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/Atomics.h ('k') | third_party/WebKit/Source/wtf/BitVector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698