OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 } | 61 } |
62 return false; | 62 return false; |
63 } | 63 } |
64 | 64 |
65 bool SelectRuleFeatureSet::checkSelectorsForClassChange( | 65 bool SelectRuleFeatureSet::checkSelectorsForClassChange( |
66 const SpaceSplitString& oldClasses, | 66 const SpaceSplitString& oldClasses, |
67 const SpaceSplitString& newClasses) const { | 67 const SpaceSplitString& newClasses) const { |
68 if (!oldClasses.size()) | 68 if (!oldClasses.size()) |
69 return checkSelectorsForClassChange(newClasses); | 69 return checkSelectorsForClassChange(newClasses); |
70 | 70 |
71 // Class vectors tend to be very short. This is faster than using a hash table
. | 71 // Class vectors tend to be very short. This is faster than using a hash |
| 72 // table. |
72 BitVector remainingClassBits; | 73 BitVector remainingClassBits; |
73 remainingClassBits.ensureSize(oldClasses.size()); | 74 remainingClassBits.ensureSize(oldClasses.size()); |
74 | 75 |
75 for (unsigned i = 0; i < newClasses.size(); ++i) { | 76 for (unsigned i = 0; i < newClasses.size(); ++i) { |
76 bool found = false; | 77 bool found = false; |
77 for (unsigned j = 0; j < oldClasses.size(); ++j) { | 78 for (unsigned j = 0; j < oldClasses.size(); ++j) { |
78 if (newClasses[i] == oldClasses[j]) { | 79 if (newClasses[i] == oldClasses[j]) { |
79 // Mark each class that is still in the newClasses so we can skip doing | 80 // Mark each class that is still in the newClasses so we can skip doing |
80 // an n^2 search below when looking for removals. We can't break from | 81 // an n^2 search below when looking for removals. We can't break from |
81 // this loop early since a class can appear more than once. | 82 // this loop early since a class can appear more than once. |
(...skipping 13 matching lines...) Expand all Loading... |
95 continue; | 96 continue; |
96 | 97 |
97 // Class was removed. | 98 // Class was removed. |
98 if (hasSelectorForClass(oldClasses[i])) | 99 if (hasSelectorForClass(oldClasses[i])) |
99 return true; | 100 return true; |
100 } | 101 } |
101 return false; | 102 return false; |
102 } | 103 } |
103 | 104 |
104 } // namespace blink | 105 } // namespace blink |
OLD | NEW |