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

Unified Diff: unit_test/unit_test.h

Issue 1361813002: replace random with fastrand (Closed) Base URL: https://chromium.googlesource.com/libyuv/libyuv@master
Patch Set: remove win32 version of random Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « unit_test/scale_test.cc ('k') | unit_test/unit_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: unit_test/unit_test.h
diff --git a/unit_test/unit_test.h b/unit_test/unit_test.h
index 98fb0168c01a31208882552bb80c4ae38b518c36..41eda497cd784973c794d50524355729fac67f99 100644
--- a/unit_test/unit_test.h
+++ b/unit_test/unit_test.h
@@ -46,9 +46,6 @@ static inline double get_time() {
QueryPerformanceFrequency(&f);
return static_cast<double>(t.QuadPart) / static_cast<double>(f.QuadPart);
}
-
-#define random rand
-#define srandom srand
#else
static inline double get_time() {
struct timeval t;
@@ -58,14 +55,20 @@ static inline double get_time() {
}
#endif
+extern int fastrand_seed;
+inline int fastrand() {
+ fastrand_seed = fastrand_seed * 214013 + 2531011;
+ return (fastrand_seed >> 16) & 0xffff;
+}
+
static inline void MemRandomize(uint8* dst, int64 len) {
int64 i;
for (i = 0; i < len - 1; i += 2) {
- *reinterpret_cast<uint16*>(dst) = random();
+ *reinterpret_cast<uint16*>(dst) = fastrand();
dst += 2;
}
for (; i < len; ++i) {
- *dst++ = random();
+ *dst++ = fastrand();
}
}
« no previous file with comments | « unit_test/scale_test.cc ('k') | unit_test/unit_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698