summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorfbarchard@google.com <fbarchard@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-12 02:17:30 +0000
committerfbarchard@google.com <fbarchard@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-12 02:17:30 +0000
commit2b0964296cf3381b36e9fd342199a990adb458bc (patch)
tree07e1c0982db51b26a8e745d982b6ee6643de6ea7 /media
parent65d12044f78bd469b507d89703bd3067267a94b3 (diff)
downloadchromium_src-2b0964296cf3381b36e9fd342199a990adb458bc.zip
chromium_src-2b0964296cf3381b36e9fd342199a990adb458bc.tar.gz
chromium_src-2b0964296cf3381b36e9fd342199a990adb458bc.tar.bz2
hash code cleanup - copy seed to local and use array indexing. 1.483 ms for 720p vs 2.225 ms for old code.
BUG=none TEST=none Review URL: https://chromiumcodereview.appspot.com/10052036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131901 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/base/djb2.cc14
1 files changed, 6 insertions, 8 deletions
diff --git a/media/base/djb2.cc b/media/base/djb2.cc
index 3f790ed..8d47ed2 100644
--- a/media/base/djb2.cc
+++ b/media/base/djb2.cc
@@ -1,16 +1,14 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/base/djb2.h"
-uint32 DJB2Hash(const void* buf, size_t len, uint32 hash) {
- const uint8* s = reinterpret_cast<const uint8*>(buf);
- if (len > 0) {
- do {
- hash = hash * 33 + *s++;
- } while (--len);
+uint32 DJB2Hash(const void* buf, size_t len, uint32 seed) {
+ const uint8* src = reinterpret_cast<const uint8*>(buf);
+ uint32 hash = seed;
+ for (size_t i = 0; i < len; ++i) {
+ hash = hash * 33 + src[i];
}
return hash;
}
-