Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use 3 param method for converting r,g,b into css string. #5449

Merged

Conversation

CodingFabian
Copy link
Contributor

This avoids creation of temporary arrays to pass them into the util
method. Also using "arguments" is more expensive then passing in 3
parameters.

FYI, here the benchmark which shows the cost of using 'arguments':
http://jsperf.com/arguments-or-explicit-use

@CodingFabian
Copy link
Contributor Author

i have the feeling one could avoid a few array allocations in colorspace as well, but that seemed to be way to much change for this PR.


// Enlighten the color (70%)
var r = Math.round(color[0] * 255);
r = Math.round((255 - r) * 0.7) + r;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason for the double rounding here? We could just as well use
var r = Math.round(255 * (0.3 * color[0] + 0.7));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be hones, I did not check. i just unrolled the loop. I suspect this does not really matter much. its in annotations code. the rounded result could be different however.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a constant here, e.g. var BACKGROUND_ENLIGHT = 0.7 (placed after the comment above) to not use magical 0.7 three times?

the rounded result could be different however.

I don't really like having round in color operations. Also 255 multiplication can be moved just before makeCssRgb, e.g.:

var r = BACKGROUND_ENLIGHT * (1.0 - color[0]) + color[0];
var g = BACKGROUND_ENLIGHT * (1.0 - color[1]) + color[1];
var b = BACKGROUND_ENLIGHT * (1.0 - color[2]) + color[2];
content.style.backgroundColor = Util.makeCssRgb((r * 255) | 0, (g * 255) | 0, (b * 255) | 0);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. push incoming

This avoids creation of temporary arrays to pass them into the util
method. Also using "arguments" is more expensive then passing in 3
parameters.
@timvandermeij
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

pdfjsbot commented Dec 8, 2014

From: Bot.io (Linux)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://107.21.233.14:8877/ce5a94888e2a02b/output.txt

@yurydelendik
Copy link
Contributor

/botio test

@pdfjsbot
Copy link

pdfjsbot commented Dec 8, 2014

From: Bot.io (Linux)


Received

Command cmd_test from @yurydelendik received. Current queue size: 0

Live output at: http://107.21.233.14:8877/c914bc37da211fb/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Dec 8, 2014

From: Bot.io (Windows)


Received

Command cmd_test from @yurydelendik received. Current queue size: 0

Live output at: http://107.22.172.223:8877/99447bb9b37e718/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Dec 8, 2014

From: Bot.io (Windows)


Failed

Full output at http://107.22.172.223:8877/99447bb9b37e718/output.txt

Total script time: 3.06 mins

  • Font tests: FAILED
  • Unit tests: Passed
  • Regression tests: FAILED

Image differences available at: http://107.22.172.223:8877/99447bb9b37e718/reftest-analyzer.html#web=eq.log

@yurydelendik
Copy link
Contributor

/botio-windows test

@pdfjsbot
Copy link

pdfjsbot commented Dec 8, 2014

From: Bot.io (Windows)


Received

Command cmd_test from @yurydelendik received. Current queue size: 0

Live output at: http://107.22.172.223:8877/629a6a8d337cdda/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Dec 8, 2014

From: Bot.io (Windows)


Failed

Full output at http://107.22.172.223:8877/629a6a8d337cdda/output.txt

Total script time: 16.55 mins

  • Font tests: FAILED
  • Unit tests: Passed
  • Regression tests: Passed

@pdfjsbot
Copy link

pdfjsbot commented Dec 8, 2014

From: Bot.io (Linux)


Failed

Full output at http://107.21.233.14:8877/c914bc37da211fb/output.txt

Total script time: 22.64 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: FAILED

Image differences available at: http://107.21.233.14:8877/c914bc37da211fb/reftest-analyzer.html#web=eq.log

@yurydelendik
Copy link
Contributor

patch looks good, thanks.

(looks like ff36/linux fixed gradient color, non related to this change)

/botio makeref

@pdfjsbot
Copy link

pdfjsbot commented Dec 8, 2014

From: Bot.io (Linux)


Received

Command cmd_makeref from @yurydelendik received. Current queue size: 0

Live output at: http://107.21.233.14:8877/0b4ce0ae57d403a/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Dec 8, 2014

From: Bot.io (Windows)


Received

Command cmd_makeref from @yurydelendik received. Current queue size: 0

Live output at: http://107.22.172.223:8877/a053d9b93912359/output.txt

yurydelendik added a commit that referenced this pull request Dec 8, 2014
Use 3 param method for converting r,g,b into css string.
@yurydelendik yurydelendik merged commit 3547462 into mozilla:master Dec 8, 2014
@pdfjsbot
Copy link

pdfjsbot commented Dec 8, 2014

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/a053d9b93912359/output.txt

Total script time: 16.69 mins

  • Lint: Passed
  • Make references: Passed
  • Check references: Passed

@pdfjsbot
Copy link

pdfjsbot commented Dec 8, 2014

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/0b4ce0ae57d403a/output.txt

Total script time: 22.25 mins

  • Lint: Passed
  • Make references: Passed
  • Check references: Passed

@CodingFabian CodingFabian deleted the preferParamsOverArguments branch December 15, 2014 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants