hbfastset.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * @file hbfastset.h
  3. *
  4. * $LicenseInfo:firstyear=2020&license=viewergpl$
  5. *
  6. * Copyright (c) 2020, Henri Beauchamp.
  7. *
  8. * Second Life Viewer Source Code
  9. * The source code in this file ("Source Code") is provided by Linden Lab
  10. * to you under the terms of the GNU General Public License, version 2.0
  11. * ("GPL"), unless you have obtained a separate licensing agreement
  12. * ("Other License"), formally executed by you and Linden Lab. Terms of
  13. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  14. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  15. *
  16. * There are special exceptions to the terms and conditions of the GPL as
  17. * it is applied to this Source Code. View the full text of the exception
  18. * in the file doc/FLOSS-exception.txt in this software distribution, or
  19. * online at
  20. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  21. *
  22. * By copying, modifying or distributing this software, you acknowledge
  23. * that you have read and understood your obligations described above,
  24. * and agree to abide by those obligations.
  25. *
  26. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  27. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  28. * COMPLETENESS OR PERFORMANCE.
  29. * $/LicenseInfo$
  30. */
  31. #ifndef LL_HBFASTSET_H
  32. #define LL_HBFASTSET_H
  33. // safe_hset, fast_hset and flat_hset are the macros to use (for example, in
  34. // place of boost::unordered_set or boost::container::flat_set) for unordered
  35. // sets you wish to (potentially) speed up.
  36. // safe_hset is guaranteed not to invalidate all the map iterators on erase()
  37. // of one of its elements and to preserve pointers.
  38. // The hset_erase #define is provided for a minor optimization with phmap
  39. // containers, that may call a special _erase() method, that does not return
  40. // an iterator (unlike erase()) and is therefore slightly faster. It is only
  41. // valid when passed an iterator (const or not).
  42. #if LL_NO_PHMAP
  43. # include "boost/unordered_set.hpp"
  44. # include "boost/container/flat_set.hpp"
  45. # define safe_hset boost::unordered_set
  46. # define fast_hset boost::unordered_set
  47. # define flat_hset boost::container::flat_set
  48. # define hset_erase(it) erase(it)
  49. #else
  50. # include "parallel_hashmap/phmap.h"
  51. # define safe_hset phmap::node_hash_set
  52. # define fast_hset phmap::flat_hash_set
  53. # define flat_hset phmap::flat_hash_set
  54. # define hset_erase(it) _erase(it)
  55. #endif
  56. #endif // LL_HBFASTSET_H