Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Unified Diff: tracing/tracing/base/math/piecewise_linear_function.html

Issue 2776653002: [ESLint] Fix violations when enabling curly rule in eslint. (Closed)
Patch Set: rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tracing/tracing/base/math/math.html ('k') | tracing/tracing/base/math/quad.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tracing/tracing/base/math/piecewise_linear_function.html
diff --git a/tracing/tracing/base/math/piecewise_linear_function.html b/tracing/tracing/base/math/piecewise_linear_function.html
index b97b781e14d9ffb37266d3ff71078402b6df390e..014cad0ba1021c02cc695a816a1e37fb5f1ceab0 100644
--- a/tracing/tracing/base/math/piecewise_linear_function.html
+++ b/tracing/tracing/base/math/piecewise_linear_function.html
@@ -28,14 +28,16 @@ tr.exportTo('tr.b.math', function() {
* Pieces must be pushed in the order of increasing x coordinate.
*/
push: function(x1, y1, x2, y2) {
- if (x1 >= x2)
+ if (x1 >= x2) {
throw new Error('Invalid segment');
+ }
if (this.pieces.length > 0 &&
this.pieces[this.pieces.length - 1].x2 > x1) {
throw new Error('Potentially overlapping segments');
}
- if (x1 < x2)
+ if (x1 < x2) {
this.pieces.push(new Piece(x1, y1, x2, y2));
+ }
},
/**
@@ -60,8 +62,7 @@ tr.exportTo('tr.b.math', function() {
weightedSum += piece.width * piece.average;
totalWeight += piece.width;
});
- if (totalWeight === 0)
- return 0;
+ if (totalWeight === 0) return 0;
return weightedSum / totalWeight;
},
@@ -70,20 +71,21 @@ tr.exportTo('tr.b.math', function() {
* that have f(x) <= y is approximately equal to the given |percent|.
*/
percentile: function(percent) {
- if (!(percent >= 0 && percent <= 1))
+ if (!(percent >= 0 && percent <= 1)) {
throw new Error('percent must be [0,1]');
+ }
var lower = this.min;
var upper = this.max;
var total = this.partBelow(upper);
- if (total === 0)
- return 0;
+ if (total === 0) return 0;
while (upper - lower > PERCENTILE_PRECISION) {
var middle = (lower + upper) / 2;
var below = this.partBelow(middle);
- if (below / total < percent)
+ if (below / total < percent) {
lower = middle;
- else
+ } else {
upper = middle;
+ }
}
return (lower + upper) / 2;
}
@@ -108,14 +110,11 @@ tr.exportTo('tr.b.math', function() {
*/
partBelow: function(y) {
var width = this.width;
- if (width === 0)
- return 0;
+ if (width === 0) return 0;
var minY = this.min;
var maxY = this.max;
- if (y >= maxY)
- return width;
- if (y < minY)
- return 0;
+ if (y >= maxY) return width;
+ if (y < minY) return 0;
return (y - minY) / (maxY - minY) * width;
},
« no previous file with comments | « tracing/tracing/base/math/math.html ('k') | tracing/tracing/base/math/quad.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698