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

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

Issue 1611343002: wtf reformat test Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pydent Created 4 years, 11 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
« 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 14 matching lines...) Expand all
25 25
26 #ifndef BitArray_h 26 #ifndef BitArray_h
27 #define BitArray_h 27 #define BitArray_h
28 28
29 #include "wtf/Allocator.h" 29 #include "wtf/Allocator.h"
30 #include "wtf/Assertions.h" 30 #include "wtf/Assertions.h"
31 #include <string.h> 31 #include <string.h>
32 32
33 namespace WTF { 33 namespace WTF {
34 34
35 template<unsigned arraySize> 35 template <unsigned arraySize>
36 class BitArray { 36 class BitArray {
37 USING_FAST_MALLOC(BitArray); 37 USING_FAST_MALLOC(BitArray);
38 public:
39 BitArray(bool value = false)
40 {
41 memset(m_data, value ? 0xFF : 0, sizeof(m_data));
42 }
43 38
44 void set(unsigned index) 39 public:
45 { 40 BitArray(bool value = false) {
46 ASSERT_WITH_SECURITY_IMPLICATION(index < arraySize); 41 memset(m_data, value ? 0xFF : 0, sizeof(m_data));
47 m_data[index / 8] |= 1 << (index & 7); 42 }
48 }
49 43
50 void clear(unsigned index) 44 void set(unsigned index) {
51 { 45 ASSERT_WITH_SECURITY_IMPLICATION(index < arraySize);
52 ASSERT_WITH_SECURITY_IMPLICATION(index < arraySize); 46 m_data[index / 8] |= 1 << (index & 7);
53 m_data[index / 8] &= ~(1 << (index & 7)); 47 }
54 }
55 48
56 bool get(unsigned index) const 49 void clear(unsigned index) {
57 { 50 ASSERT_WITH_SECURITY_IMPLICATION(index < arraySize);
58 ASSERT_WITH_SECURITY_IMPLICATION(index < arraySize); 51 m_data[index / 8] &= ~(1 << (index & 7));
59 return !!(m_data[index / 8] & (1 << (index & 7))); 52 }
60 }
61 53
62 private: 54 bool get(unsigned index) const {
63 unsigned char m_data[arraySize / 8 + 1]; 55 ASSERT_WITH_SECURITY_IMPLICATION(index < arraySize);
56 return !!(m_data[index / 8] & (1 << (index & 7)));
57 }
58
59 private:
60 unsigned char m_data[arraySize / 8 + 1];
64 }; 61 };
65 62
66 } // namespace WTF 63 } // namespace WTF
67 64
68 using WTF::BitArray; 65 using WTF::BitArray;
69 66
70 #endif // BitArray_h 67 #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