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

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

Issue 290793004: Use a BitArray in RuntimeCSSEnabled instead of a Vector<bool> (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix bug in clear() Created 6 years, 7 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
« no previous file with comments | « Source/core/css/RuntimeCSSEnabled.cpp ('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) 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 16 matching lines...) Expand all
27 #define BitArray_h 27 #define BitArray_h
28 28
29 #include <string.h> 29 #include <string.h>
30 #include "wtf/Assertions.h" 30 #include "wtf/Assertions.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() 37 BitArray(bool value = false)
38 { 38 {
39 memset(m_data, 0, sizeof(m_data)); 39 memset(m_data, value ? 0xFF : 0, sizeof(m_data));
40 } 40 }
41 41
42 void set(unsigned index) 42 void set(unsigned index)
43 { 43 {
44 ASSERT_WITH_SECURITY_IMPLICATION(index < arraySize); 44 ASSERT_WITH_SECURITY_IMPLICATION(index < arraySize);
45 m_data[index / 8] |= 1 << (index & 7); 45 m_data[index / 8] |= 1 << (index & 7);
46 } 46 }
47 47
48 void clear(unsigned index)
49 {
50 ASSERT_WITH_SECURITY_IMPLICATION(index < arraySize);
51 m_data[index / 8] &= ~(1 << (index & 7));
52 }
53
48 bool get(unsigned index) const 54 bool get(unsigned index) const
49 { 55 {
50 ASSERT_WITH_SECURITY_IMPLICATION(index < arraySize); 56 ASSERT_WITH_SECURITY_IMPLICATION(index < arraySize);
51 return !!(m_data[index / 8] & (1 << (index & 7))); 57 return !!(m_data[index / 8] & (1 << (index & 7)));
52 } 58 }
53 59
54 private: 60 private:
55 unsigned char m_data[arraySize / 8 + 1]; 61 unsigned char m_data[arraySize / 8 + 1];
56 }; 62 };
57 63
58 } // namespace WTF 64 } // namespace WTF
59 65
60 using WTF::BitArray; 66 using WTF::BitArray;
61 67
62 #endif // BitArray_h 68 #endif // BitArray_h
OLDNEW
« no previous file with comments | « Source/core/css/RuntimeCSSEnabled.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698