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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 oldMap[oldIndex].second = newIndex; | 237 oldMap[oldIndex].second = newIndex; |
238 newMap[newIndex].first = newList[newIndex].get(); | 238 newMap[newIndex].first = newList[newIndex].get(); |
239 newMap[newIndex].second = oldIndex; | 239 newMap[newIndex].second = oldIndex; |
240 } | 240 } |
241 | 241 |
242 typedef HashMap<String, Vector<size_t> > DiffTable; | 242 typedef HashMap<String, Vector<size_t> > DiffTable; |
243 DiffTable newTable; | 243 DiffTable newTable; |
244 DiffTable oldTable; | 244 DiffTable oldTable; |
245 | 245 |
246 for (size_t i = 0; i < newList.size(); ++i) { | 246 for (size_t i = 0; i < newList.size(); ++i) { |
247 DiffTable::iterator it = newTable.add(newList[i]->m_sha1, Vector<size_t>
()).iterator; | 247 newTable.add(newList[i]->m_sha1, Vector<size_t>()).iterator->value.appen
d(i); |
248 it->value.append(i); | |
249 } | 248 } |
250 | 249 |
251 for (size_t i = 0; i < oldList.size(); ++i) { | 250 for (size_t i = 0; i < oldList.size(); ++i) { |
252 DiffTable::iterator it = oldTable.add(oldList[i]->m_sha1, Vector<size_t>
()).iterator; | 251 oldTable.add(oldList[i]->m_sha1, Vector<size_t>()).iterator->value.appen
d(i); |
253 it->value.append(i); | |
254 } | 252 } |
255 | 253 |
256 for (DiffTable::iterator newIt = newTable.begin(); newIt != newTable.end();
++newIt) { | 254 for (DiffTable::iterator newIt = newTable.begin(); newIt != newTable.end();
++newIt) { |
257 if (newIt->value.size() != 1) | 255 if (newIt->value.size() != 1) |
258 continue; | 256 continue; |
259 | 257 |
260 DiffTable::iterator oldIt = oldTable.find(newIt->key); | 258 DiffTable::iterator oldIt = oldTable.find(newIt->key); |
261 if (oldIt == oldTable.end() || oldIt->value.size() != 1) | 259 if (oldIt == oldTable.end() || oldIt->value.size() != 1) |
262 continue; | 260 continue; |
263 | 261 |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 void DOMPatchSupport::dumpMap(const ResultMap& map, const String& name) | 506 void DOMPatchSupport::dumpMap(const ResultMap& map, const String& name) |
509 { | 507 { |
510 fprintf(stderr, "\n\n"); | 508 fprintf(stderr, "\n\n"); |
511 for (size_t i = 0; i < map.size(); ++i) | 509 for (size_t i = 0; i < map.size(); ++i) |
512 fprintf(stderr, "%s[%lu]: %s (%p) - [%lu]\n", name.utf8().data(), i, map
[i].first ? nodeName(map[i].first->m_node).utf8().data() : "", map[i].first, map
[i].second); | 510 fprintf(stderr, "%s[%lu]: %s (%p) - [%lu]\n", name.utf8().data(), i, map
[i].first ? nodeName(map[i].first->m_node).utf8().data() : "", map[i].first, map
[i].second); |
513 } | 511 } |
514 #endif | 512 #endif |
515 | 513 |
516 } // namespace WebCore | 514 } // namespace WebCore |
517 | 515 |
OLD | NEW |