| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkRecordPattern_DEFINED | 8 #ifndef SkRecordPattern_DEFINED |
| 9 #define SkRecordPattern_DEFINED | 9 #define SkRecordPattern_DEFINED |
| 10 | 10 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 template <typename T> T* first() { return fFirst.get(); } | 140 template <typename T> T* first() { return fFirst.get(); } |
| 141 template <typename T> T* second() { return fRest.template first<T>(); } | 141 template <typename T> T* second() { return fRest.template first<T>(); } |
| 142 template <typename T> T* third() { return fRest.template second<T>(); } | 142 template <typename T> T* third() { return fRest.template second<T>(); } |
| 143 template <typename T> T* fourth() { return fRest.template third<T>(); } | 143 template <typename T> T* fourth() { return fRest.template third<T>(); } |
| 144 | 144 |
| 145 private: | 145 private: |
| 146 // If first isn't a Greedy, try to match at i once. | 146 // If first isn't a Greedy, try to match at i once. |
| 147 template <typename T> | 147 template <typename T> |
| 148 int matchFirst(T* first, SkRecord* record, int i) { | 148 int matchFirst(T* first, SkRecord* record, int i) { |
| 149 if (i < record->count()) { | 149 if (i < record->count()) { |
| 150 if (record->mutate<bool>(i, *first)) { | 150 if (record->mutate(i, *first)) { |
| 151 return i+1; | 151 return i+1; |
| 152 } | 152 } |
| 153 } | 153 } |
| 154 return 0; | 154 return 0; |
| 155 } | 155 } |
| 156 | 156 |
| 157 // If first is a Greedy, walk i until it doesn't match. | 157 // If first is a Greedy, walk i until it doesn't match. |
| 158 template <typename T> | 158 template <typename T> |
| 159 int matchFirst(Greedy<T>* first, SkRecord* record, int i) { | 159 int matchFirst(Greedy<T>* first, SkRecord* record, int i) { |
| 160 while (i < record->count()) { | 160 while (i < record->count()) { |
| 161 if (!record->mutate<bool>(i, *first)) { | 161 if (!record->mutate(i, *first)) { |
| 162 return i; | 162 return i; |
| 163 } | 163 } |
| 164 i++; | 164 i++; |
| 165 } | 165 } |
| 166 return 0; | 166 return 0; |
| 167 } | 167 } |
| 168 | 168 |
| 169 First fFirst; | 169 First fFirst; |
| 170 Pattern<Rest...> fRest; | 170 Pattern<Rest...> fRest; |
| 171 }; | 171 }; |
| 172 | 172 |
| 173 } // namespace SkRecords | 173 } // namespace SkRecords |
| 174 | 174 |
| 175 #endif//SkRecordPattern_DEFINED | 175 #endif//SkRecordPattern_DEFINED |
| OLD | NEW |