mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 09:45:42 +02:00
Use Math.hypot
, instead of Math.sqrt
with manual squaring (#12973)
When the PDF.js project started `Math.hypot` didn't exist yet, and until recently we still supported browsers (IE 11) without a native `Math.hypot` implementation; please see this compatibility information: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot#browser_compatibility Furthermore, somewhat recently there were performance improvements of `Math.hypot` in Firefox; see https://bugzilla.mozilla.org/show_bug.cgi?id=1648820 Finally, this patch also replaces a couple of multiplications with the exponentiation operator.
This commit is contained in:
parent
3a2c259b57
commit
31098c404d
8 changed files with 23 additions and 27 deletions
|
@ -720,7 +720,7 @@ class Util {
|
|||
|
||||
// Solve the second degree polynomial to get roots.
|
||||
const first = (a + d) / 2;
|
||||
const second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
|
||||
const second = Math.sqrt((a + d) ** 2 - 4 * (a * d - c * b)) / 2;
|
||||
const sx = first + second || 1;
|
||||
const sy = first - second || 1;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue