| Conditions | 3 |
| Total Lines | 51 |
| Code Lines | 38 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | /** |
||
| 14 | function murmurhash3_32_gc(key, seed) { |
||
| 15 | var remainder, bytes, h1, h1b, c1, c1b, c2, c2b, k1, i; |
||
| 16 | |||
| 17 | remainder = key.length & 3; // key.length % 4 |
||
| 18 | bytes = key.length - remainder; |
||
| 19 | h1 = seed; |
||
| 20 | c1 = 0xcc9e2d51; |
||
| 21 | c2 = 0x1b873593; |
||
| 22 | i = 0; |
||
| 23 | |||
| 24 | while (i < bytes) { |
||
| 25 | k1 = |
||
| 26 | ((key.charCodeAt(i) & 0xff)) | |
||
| 27 | ((key.charCodeAt(++i) & 0xff) << 8) | |
||
| 28 | ((key.charCodeAt(++i) & 0xff) << 16) | |
||
| 29 | ((key.charCodeAt(++i) & 0xff) << 24); |
||
| 30 | ++i; |
||
| 31 | |||
| 32 | k1 = ((((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16))) & 0xffffffff; |
||
| 33 | k1 = (k1 << 15) | (k1 >>> 17); |
||
| 34 | k1 = ((((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16))) & 0xffffffff; |
||
| 35 | |||
| 36 | h1 ^= k1; |
||
| 37 | h1 = (h1 << 13) | (h1 >>> 19); |
||
| 38 | h1b = ((((h1 & 0xffff) * 5) + ((((h1 >>> 16) * 5) & 0xffff) << 16))) & 0xffffffff; |
||
| 39 | h1 = (((h1b & 0xffff) + 0x6b64) + ((((h1b >>> 16) + 0xe654) & 0xffff) << 16)); |
||
| 40 | } |
||
| 41 | |||
| 42 | k1 = 0; |
||
| 43 | |||
| 44 | switch (remainder) { |
||
| 45 | case 3: k1 ^= (key.charCodeAt(i + 2) & 0xff) << 16; |
||
| 46 | case 2: k1 ^= (key.charCodeAt(i + 1) & 0xff) << 8; |
||
| 47 | case 1: k1 ^= (key.charCodeAt(i) & 0xff); |
||
| 48 | |||
| 49 | k1 = (((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16)) & 0xffffffff; |
||
| 50 | k1 = (k1 << 15) | (k1 >>> 17); |
||
| 51 | k1 = (((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16)) & 0xffffffff; |
||
| 52 | h1 ^= k1; |
||
| 53 | } |
||
| 54 | |||
| 55 | h1 ^= key.length; |
||
| 56 | |||
| 57 | h1 ^= h1 >>> 16; |
||
| 58 | h1 = (((h1 & 0xffff) * 0x85ebca6b) + ((((h1 >>> 16) * 0x85ebca6b) & 0xffff) << 16)) & 0xffffffff; |
||
| 59 | h1 ^= h1 >>> 13; |
||
| 60 | h1 = ((((h1 & 0xffff) * 0xc2b2ae35) + ((((h1 >>> 16) * 0xc2b2ae35) & 0xffff) << 16))) & 0xffffffff; |
||
| 61 | h1 ^= h1 >>> 16; |
||
| 62 | |||
| 63 | return h1 >>> 0; |
||
| 64 | } |