Permalink
Browse files

Use the faster bitwise operator instead of Math.floor and parseInt.

  • Loading branch information...
1 parent c9df582 commit 4a426d923ce53da512d60ef33fe3cb6460f0ab4d @blueimp committed Mar 11, 2013
Showing with 6 additions and 6 deletions.
  1. +6 −6 load-image.js
View
@@ -145,8 +145,8 @@
0,
sw,
sh,
- Math.floor(sx * width / iw),
- Math.floor(sy * height / ih / vertSquashRatio),
+ (sx * width / iw) << 0,
+ (sy * height / ih / vertSquashRatio) << 0,
Math.ceil(sw * width / iw),
Math.ceil(sh * height / ih / vertSquashRatio)
);
@@ -173,16 +173,16 @@
(options.minHeight || height) / height
);
if (scale > 1) {
- width = parseInt(width * scale, 10);
- height = parseInt(height * scale, 10);
+ width = (width * scale) << 0;
+ height = (height * scale) << 0;
}
scale = Math.min(
(options.maxWidth || width) / width,
(options.maxHeight || height) / height
);
if (scale < 1) {
- width = parseInt(width * scale, 10);
- height = parseInt(height * scale, 10);
+ width = (width * scale) << 0;
+ height = (height * scale) << 0;
}
if (img.getContext || (options.canvas && canvas.getContext)) {
canvas.width = width;

0 comments on commit 4a426d9

Please sign in to comment.