summaryrefslogtreecommitdiff
path: root/src/cairo-path-fixed.c
diff options
context:
space:
mode:
authorAndrea Canciani <ranma42@gmail.com>2010-10-17 10:55:15 +0200
committerAndrea Canciani <ranma42@gmail.com>2010-10-29 17:31:21 +0200
commitf4b2ce1c78c05c0a551aab7c84451c7ee1759213 (patch)
tree117ee25eb4f79ae1f390b74531602a9e412c942a /src/cairo-path-fixed.c
parente9c1fc31887c5bfbb7d086f923a7628b7cfa739c (diff)
downloadcairo-f4b2ce1c78c05c0a551aab7c84451c7ee1759213.tar.gz
path: Improve hashing
Make the hash independent of buf bucketing, extents and flags. This makes the hash depend only on the actual content of the path, not on how it is stored or on any computed property.
Diffstat (limited to 'src/cairo-path-fixed.c')
-rw-r--r--src/cairo-path-fixed.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/cairo-path-fixed.c b/src/cairo-path-fixed.c
index b6495e1d7..96dd0eb14 100644
--- a/src/cairo-path-fixed.c
+++ b/src/cairo-path-fixed.c
@@ -182,23 +182,23 @@ _cairo_path_fixed_hash (const cairo_path_fixed_t *path)
{
unsigned long hash = _CAIRO_HASH_INIT_VALUE;
const cairo_path_buf_t *buf;
- int num_points, num_ops;
-
- hash = _cairo_hash_bytes (hash, &path->extents, sizeof (path->extents));
+ unsigned int count;
- num_ops = num_points = 0;
+ count = 0;
cairo_path_foreach_buf_start (buf, path) {
hash = _cairo_hash_bytes (hash, buf->op,
buf->num_ops * sizeof (buf->op[0]));
+ count += buf->num_ops;
+ } cairo_path_foreach_buf_end (buf, path);
+ hash = _cairo_hash_bytes (hash, &count, sizeof (count));
+
+ count = 0;
+ cairo_path_foreach_buf_start (buf, path) {
hash = _cairo_hash_bytes (hash, buf->points,
buf->num_points * sizeof (buf->points[0]));
-
- num_ops += buf->num_ops;
- num_points += buf->num_points;
+ count += buf->num_points;
} cairo_path_foreach_buf_end (buf, path);
-
- hash = _cairo_hash_bytes (hash, &num_ops, sizeof (num_ops));
- hash = _cairo_hash_bytes (hash, &num_points, sizeof (num_points));
+ hash = _cairo_hash_bytes (hash, &count, sizeof (count));
return hash;
}