Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Optimized hex16 and hex32 functions.

  • Loading branch information...
commit d2bdb13f65eb1bbaee1def16b5caf1fe83083da8 1 parent 7b9146d
Alex Gorbatchev authored
Showing with 2 additions and 21 deletions.
  1. +2 −21 lib/crc.js
View
23 lib/crc.js
@@ -328,13 +328,7 @@ define([], function()
*/
function hex16(val)
{
- var n=val&0xFFFF;
- var str=n.toString(16).toUpperCase();
- while (str.length<4)
- {
- str="0"+str;
- }
- return str;
+ return hex8(val >> 8) + hex8(val);
}
/**
@@ -342,20 +336,7 @@ define([], function()
*/
function hex32(val)
{
- var str2;
- var n=val&0xFFFF;
- var str1=n.toString(16).toUpperCase();
- while (str1.length<4)
- {
- str1="0"+str1;
- }
- n=(val>>>16)&0xFFFF;
- str2=n.toString(16).toUpperCase();
- while (str2.length<4)
- {
- str2="0"+str2;
- }
- return str2+str1;
+ return hex16(val >> 16) + hex16(val);
}
return {
Please sign in to comment.
Something went wrong with that request. Please try again.