Skip to content

[WIP] fix: decimal step cause divide not equal #228

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

Closed
wants to merge 1 commit into from

Conversation

paranoidjk
Copy link
Member

close #227

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.6%) to 49.793% when pulling 7395d99 on fix/decimal-step into 4e26da5 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.04%) to 49.383% when pulling a132e78 on fix/decimal-step into 4e26da5 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+5.5%) to 55.967% when pulling d57068d on fix/decimal-step into 4e26da5 on master.

@paranoidjk
Copy link
Member Author

ping @benjycui

src/Range.jsx Outdated
@@ -176,10 +176,17 @@ class Range extends React.Component {
const { marks, step, min, max } = this.props;
const cache = this._getPointsCache;
if (!cache || cache.marks !== marks || cache.step !== step) {
const decimal = step.toString().split('.')[1] && step.toString().split('.')[1].length;
Copy link
Member

Choose a reason for hiding this comment

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

Use getPrecision

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

src/Range.jsx Outdated
const pointsObject = { ...marks };
if (step !== null) {
for (let point = min; point <= max; point += step) {
let point = min;
while (point <= max) {
Copy link
Member

Choose a reason for hiding this comment

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

This loop will cost a lot.

e.g. min = 0 && max = 99999

Copy link
Member

Choose a reason for hiding this comment

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

#46

Copy link
Member Author

@paranoidjk paranoidjk Mar 1, 2017

Choose a reason for hiding this comment

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

the performance problem only occur when users set step to be a very small decimals, I think it's not our worries ?

Copy link
Member Author

Choose a reason for hiding this comment

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

maybe use something like binary search + Array.map to caculate the point more quickly?

Copy link
Member Author

Choose a reason for hiding this comment

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

caculate the point more quickly ——> avoid Maximum call stack

Copy link
Member Author

Choose a reason for hiding this comment

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

Another idea, what if when step is very small compare to max - min, we don't calculate the whole points array at first, instead just get the formula,something like: value = f(index), then the cost just happen when every time getter

@paranoidjk paranoidjk changed the title fix: decimal step cause divide not equal [WIP] fix: decimal step cause divide not equal Mar 1, 2017
@paranoidjk
Copy link
Member Author

close. going to open a new pr to fix the decimal step problem.

@paranoidjk paranoidjk closed this Mar 1, 2017
@paranoidjk paranoidjk deleted the fix/decimal-step branch March 1, 2017 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pushable only works in positive direction with decimal steps
3 participants