gfwilliams / EspruinoCompiler

Node.js-based JavaScript->C++ compiler
25 stars 3 forks source link

Make sure ^= (and others) work with ints #8

Open gfwilliams opened 9 years ago

gfwilliams commented 9 years ago

Something like this:

function checksum(m) { 
  "compiled"; 
  var ck = 0;
  var l = 0|m.length;
  var c = m.charCodeAt.bind(m);
  for (var i=0;i<l;i++) ck ^= c(i);
  return ck;
}

Isn't as fast as it could be, because ck is treated as a JsVar, not an int.