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

Side by Side Diff: src/utils.cc

Issue 646007: Kill some unused code. (Closed)
Patch Set: some more Created 10 years, 10 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 unified diff | Download patch
« no previous file with comments | « src/utils.h ('k') | test/cctest/test-utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 x = x - 1; 44 x = x - 1;
45 x = x | (x >> 1); 45 x = x | (x >> 1);
46 x = x | (x >> 2); 46 x = x | (x >> 2);
47 x = x | (x >> 4); 47 x = x | (x >> 4);
48 x = x | (x >> 8); 48 x = x | (x >> 8);
49 x = x | (x >> 16); 49 x = x | (x >> 16);
50 return x + 1; 50 return x + 1;
51 } 51 }
52 52
53 53
54 byte* EncodeInt(byte* p, int x) {
55 while (x < -64 || x >= 64) {
56 *p++ = static_cast<byte>(x & 127);
57 x = ArithmeticShiftRight(x, 7);
58 }
59 // -64 <= x && x < 64
60 *p++ = static_cast<byte>(x + 192);
61 return p;
62 }
63
64
65 byte* DecodeInt(byte* p, int* x) {
66 int r = 0;
67 unsigned int s = 0;
68 byte b = *p++;
69 while (b < 128) {
70 r |= static_cast<int>(b) << s;
71 s += 7;
72 b = *p++;
73 }
74 // b >= 128
75 *x = r | ((static_cast<int>(b) - 192) << s);
76 return p;
77 }
78
79
80 byte* EncodeUnsignedIntBackward(byte* p, unsigned int x) {
81 while (x >= 128) {
82 *--p = static_cast<byte>(x & 127);
83 x = x >> 7;
84 }
85 // x < 128
86 *--p = static_cast<byte>(x + 128);
87 return p;
88 }
89
90
91 // Thomas Wang, Integer Hash Functions. 54 // Thomas Wang, Integer Hash Functions.
92 // http://www.concentric.net/~Ttwang/tech/inthash.htm 55 // http://www.concentric.net/~Ttwang/tech/inthash.htm
93 uint32_t ComputeIntegerHash(uint32_t key) { 56 uint32_t ComputeIntegerHash(uint32_t key) {
94 uint32_t hash = key; 57 uint32_t hash = key;
95 hash = ~hash + (hash << 15); // hash = (hash << 15) - hash - 1; 58 hash = ~hash + (hash << 15); // hash = (hash << 15) - hash - 1;
96 hash = hash ^ (hash >> 12); 59 hash = hash ^ (hash >> 12);
97 hash = hash + (hash << 2); 60 hash = hash + (hash << 2);
98 hash = hash ^ (hash >> 4); 61 hash = hash ^ (hash >> 4);
99 hash = hash * 2057; // hash = (hash + (hash << 3)) + (hash << 11); 62 hash = hash * 2057; // hash = (hash + (hash << 3)) + (hash << 11);
100 hash = hash ^ (hash >> 16); 63 hash = hash ^ (hash >> 16);
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 276
314 int TenToThe(int exponent) { 277 int TenToThe(int exponent) {
315 ASSERT(exponent <= 9); 278 ASSERT(exponent <= 9);
316 ASSERT(exponent >= 1); 279 ASSERT(exponent >= 1);
317 int answer = 10; 280 int answer = 10;
318 for (int i = 1; i < exponent; i++) answer *= 10; 281 for (int i = 1; i < exponent; i++) answer *= 10;
319 return answer; 282 return answer;
320 } 283 }
321 284
322 } } // namespace v8::internal 285 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/utils.h ('k') | test/cctest/test-utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698