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

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

Issue 373423003: Save 100-300 KB footprint by not force inlining HashTable functions Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Non-inlined HashTable: Rebased to newer origin/master Created 6 years, 2 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 | « Source/wtf/HashFunctions.h ('k') | Source/wtf/HashTable.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) 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 { 418 {
419 iterator it = find(key); 419 iterator it = find(key);
420 if (it == end()) 420 if (it == end())
421 return MappedTraits::passOut(MappedTraits::emptyValue()); 421 return MappedTraits::passOut(MappedTraits::emptyValue());
422 MappedPassOutType result = MappedTraits::passOut(it->value); 422 MappedPassOutType result = MappedTraits::passOut(it->value);
423 remove(it); 423 remove(it);
424 return result; 424 return result;
425 } 425 }
426 426
427 template<typename T, typename U, typename V, typename W, typename X, typenam e Y> 427 template<typename T, typename U, typename V, typename W, typename X, typenam e Y>
428 inline bool HashMap<T, U, V, W, X, Y>::isValidKey(KeyPeekInType key) 428 bool HashMap<T, U, V, W, X, Y>::isValidKey(KeyPeekInType key)
429 { 429 {
430 if (KeyTraits::isDeletedValue(key)) 430 if (KeyTraits::isDeletedValue(key))
431 return false; 431 return false;
432 432
433 if (HashFunctions::safeToCompareToEmptyOrDeleted) { 433 if (HashFunctions::safeToCompareToEmptyOrDeleted) {
434 if (key == KeyTraits::emptyValue()) 434 if (key == KeyTraits::emptyValue())
435 return false; 435 return false;
436 } else { 436 } else {
437 if (isHashTraitsEmptyValue<KeyTraits>(key)) 437 if (isHashTraitsEmptyValue<KeyTraits>(key))
438 return false; 438 return false;
(...skipping 21 matching lines...) Expand all
460 return true; 460 return true;
461 } 461 }
462 462
463 template<typename T, typename U, typename V, typename W, typename X, typenam e Y> 463 template<typename T, typename U, typename V, typename W, typename X, typenam e Y>
464 inline bool operator!=(const HashMap<T, U, V, W, X, Y>& a, const HashMap<T, U, V, W, X, Y>& b) 464 inline bool operator!=(const HashMap<T, U, V, W, X, Y>& a, const HashMap<T, U, V, W, X, Y>& b)
465 { 465 {
466 return !(a == b); 466 return !(a == b);
467 } 467 }
468 468
469 template<typename T, typename U, typename V, typename W, typename X, typenam e Y, typename Z> 469 template<typename T, typename U, typename V, typename W, typename X, typenam e Y, typename Z>
470 inline void copyKeysToVector(const HashMap<T, U, V, W, X, Y>& collection, Z& vector) 470 void copyKeysToVector(const HashMap<T, U, V, W, X, Y>& collection, Z& vector )
471 { 471 {
472 typedef typename HashMap<T, U, V, W, X, Y>::const_iterator::Keys iterato r; 472 typedef typename HashMap<T, U, V, W, X, Y>::const_iterator::Keys iterato r;
473 473
474 vector.resize(collection.size()); 474 vector.resize(collection.size());
475 475
476 iterator it = collection.begin().keys(); 476 iterator it = collection.begin().keys();
477 iterator end = collection.end().keys(); 477 iterator end = collection.end().keys();
478 for (unsigned i = 0; it != end; ++it, ++i) 478 for (unsigned i = 0; it != end; ++it, ++i)
479 vector[i] = *it; 479 vector[i] = *it;
480 } 480 }
481 481
482 template<typename T, typename U, typename V, typename W, typename X, typenam e Y, typename Z> 482 template<typename T, typename U, typename V, typename W, typename X, typenam e Y, typename Z>
483 inline void copyValuesToVector(const HashMap<T, U, V, W, X, Y>& collection, Z& vector) 483 void copyValuesToVector(const HashMap<T, U, V, W, X, Y>& collection, Z& vect or)
484 { 484 {
485 typedef typename HashMap<T, U, V, W, X, Y>::const_iterator::Values itera tor; 485 typedef typename HashMap<T, U, V, W, X, Y>::const_iterator::Values itera tor;
486 486
487 vector.resize(collection.size()); 487 vector.resize(collection.size());
488 488
489 iterator it = collection.begin().values(); 489 iterator it = collection.begin().values();
490 iterator end = collection.end().values(); 490 iterator end = collection.end().values();
491 for (unsigned i = 0; it != end; ++it, ++i) 491 for (unsigned i = 0; it != end; ++it, ++i)
492 vector[i] = *it; 492 vector[i] = *it;
493 } 493 }
494 494
495 #if !ENABLE(OILPAN) 495 #if !ENABLE(OILPAN)
496 template<typename T, typename U, typename V, typename W, typename X> 496 template<typename T, typename U, typename V, typename W, typename X>
497 struct NeedsTracing<HashMap<T, U, V, W, X> > { 497 struct NeedsTracing<HashMap<T, U, V, W, X> > {
498 static const bool value = false; 498 static const bool value = false;
499 }; 499 };
500 #endif 500 #endif
501 501
502 } // namespace WTF 502 } // namespace WTF
503 503
504 using WTF::HashMap; 504 using WTF::HashMap;
505 505
506 #endif /* WTF_HashMap_h */ 506 #endif /* WTF_HashMap_h */
OLDNEW
« no previous file with comments | « Source/wtf/HashFunctions.h ('k') | Source/wtf/HashTable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698