Commit Graph

13 Commits

Author SHA1 Message Date
Florin Malita
053730de73 Fix SkTHashTable dangling values
The element rearrange logic in SkTHashTable::remove() marks empty slots
as such, but does not reset their value.

When breaking out of the rearrange loop, we must also reset the last empty
slot value to avoid retaining unwanted copies.

Change-Id: I8ba2a25088c0aa5210277124e0917224cb295691
Reviewed-on: https://skia-review.googlesource.com/9533
Reviewed-by: Mike Klein <mtklein@chromium.org>
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2017-03-10 17:28:04 +00:00
Mike Klein
db402cab8b add move semantics to SkTHash*
The more I look at std::unordered_map and co., the less I like them.
I think we might want to bet on SkTHash*.

As a simple first improvement, add move support.
Next comes shrinking, and then I'll start moving over SkTDynamicHash users.

BUG=skia:6053

Change-Id: Ifdb5d713aab66434ca271c7f18a0cbbb0720099c
Reviewed-on: https://skia-review.googlesource.com/5943
Commit-Queue: Mike Klein <mtklein@chromium.org>
Reviewed-by: Herb Derby <herb@google.com>
Reviewed-by: Hal Canary <halcanary@google.com>
2016-12-13 18:18:47 +00:00
mtklein
c8d1dd48c0 SkTHash: hash from fnptr to functor type
Passing &SkGoodHash to SkTHashMap and SkTHashSet doesn't guarantee that it's actually instantiated.  Using a functor does.

BUG=skia:

Review URL: https://codereview.chromium.org/1405053002
2015-10-15 12:23:02 -07:00
halcanary
96fcdcc219 Style Change: NULL->nullptr
DOCS_PREVIEW= https://skia.org/?cl=1316233002

Review URL: https://codereview.chromium.org/1316233002
2015-08-27 07:41:16 -07:00
mtklein
469a3fe6ed Add approxBytesUsed to hashes.
BUG=skia:

Review URL: https://codereview.chromium.org/1280653003
2015-08-07 09:33:37 -07:00
tfarina
567ff2f614 Cleanup: Remove unnecessary double-semicolons.
The entries were found by the following command line:

$ find . -regex ".*\.[cChH]\(pp\)?" | xargs git grep -e ';;' --and --not
-e 'for *(.*;;'

Which is a combination of http://stackoverflow.com/a/3858879 and
http://gitster.livejournal.com/27674.html

BUG=None
R=mtklein@google.com

Review URL: https://codereview.chromium.org/1088763005
2015-04-27 07:01:45 -07:00
mtklein
33d73c39dd SkTHash: remove()
BUG=skia:

Review URL: https://codereview.chromium.org/1057043003
2015-04-21 06:53:56 -07:00
mtklein
fb8307c6b7 Add SkTHashSet::find()
BUG=skia:

Review URL: https://codereview.chromium.org/1058553002
2015-04-01 11:21:27 -07:00
mtklein
02f46cf878 Some usability ideas around SkTHash.
- By default, use new SkGoodHash to hash keys, which is:
    * for 4 byte values, use SkChecksum::Mix,
    * for SkStrings, use SkChecksum::Murmur3 on the data,
    * for other structs, shallow hash the struct with Murmur3.
  - Expand SkChecksum::Murmur3 to support non-4-byte-aligned data.
  - Add const foreach() methods.
  - Have foreach() take a functor, which allows lambdas.

BUG=skia:

Review URL: https://codereview.chromium.org/1021033002
2015-03-20 13:48:42 -07:00
mtklein
2aa1f7e679 Port GrGLCaps over to use SkTHash.
I've written some new hashtable interfaces that should be easier to use,
and I've been trying to roll them out bit by bit, hopefully replacing
SkTDynamicHash, SkTMultiMap, SkTHashCache, etc.

This turns the cache in GrGLCaps::readPixelsSupported() into an SkTHashMap,
mapping the format key to a bool.  Functionally, it's the same.

BUG=skia:

Review URL: https://codereview.chromium.org/948473002
2015-02-20 12:35:32 -08:00
fmalita
79ca081b90 Minimize SkTHash object copying
AKA ref-constify the world.

R=mtklein@google.com

Review URL: https://codereview.chromium.org/919193002
2015-02-12 17:32:49 -08:00
Mike Klein
201c98d08d fix windows build
BUG=skia:

Review URL: https://codereview.chromium.org/917363002
2015-02-12 16:41:57 -05:00
mtklein
979e0eacbd Spin off SkTHashTable, SkTHashMap, SkTHashSet
SkTHashTable is very similar to SkTDynamicHash, except it's generalized to support non-pointer value types.

It doesn't support remove(), just to keep things simple (it's not hard to add).
Instead of an iterator, it has foreach(), again, to keep things simple.

SkTHashMap<K,V> and SkTHashSet<T> build a friendlier experience on top of SkTHashTable.

BUG=skia:

Review URL: https://codereview.chromium.org/925613002
2015-02-12 13:20:08 -08:00