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

fixed bug issue #3675 #4034

Closed
wants to merge 3 commits into from
Closed

fixed bug issue #3675 #4034

wants to merge 3 commits into from

Conversation

wnghdcjfe
Copy link
Contributor

@wnghdcjfe wnghdcjfe commented Sep 30, 2019

#3675
I found and fixed bug

Before entering the js diff function, there were unnecessary characters in the string, which slowed down Mocha. So I fixed it

In jsdiff structure is like that
set diff variable and logic..

lib > patch > create.js > structuredPatch

var diff =
  /*istanbul ignore start*/
  (0,
  /*istanbul ignore end*/

  /*istanbul ignore start*/
  _line
  /*istanbul ignore end*/
  .
  /*istanbul ignore start*/
  diffLines)
  /*istanbul ignore end*/
  (oldStr, newStr, options);

console.log(diff, _line.diffLines, oldStr, newStr, options)

and then.. it said like this in before mocha

 {\n    "a": 9789\n  }\n  {\n    "a": 9790\n  }\n  {\n    "a": 9791\n  }\n  {\n    "a": 9792\n  }\n  {\n    "a": 9793\n  }\n  {\n    "a": 9794\n  }\n  {\n    "a": 9795\n  }\n  {\n    "a": 9796\n  }\n  {\n    "a": 9797\n  }\n  {\n    "a": 9798\n  }\n  {\n    "a": 9799\n  }\n  {\n    "a": 9800\n  }\n  {\n    "a": 9801\n  }\n  {\n    "a": 9802\n  }\n  {\n    "a": 9803\n  }\n  {\n    "a": 9804\n  }\n  {\n    "a": 9805\n  }\n  {\n    "a": 9806\n  }\n  {\n    "a": 9807\n  }\n  {\n    "a": 9808\n  }\n  {\n    "a": 9809\n  }\n  {\n    "a": 9810\n  }\n  {\n    "a": 9811\n  }\n  {\n    "a": 9812\n  }\n  {\n    "a": 9813\n  }\n  {\n    "a": 9814\n  }\n  {\n    "a": 9815\n  }\n  {\n   

but..!!!
in only diff

"a":9949},{"a":9950},{"a":9951},{"a":9952},{"a":9953},{"a":9954},{"a":9955},{"a":9956},{"a":9957},{"a":9958},{"a":9959},{"a":9960},{"a":9961},{"a":9962},{"a":9963},{"a":9964},{"a":9965},{"a":9966},{"a":9967},{"a":9968},{"a":9969},{"a":9970},{"a":9971},{"a":9972},{"a":9973},{"a":9974},{"a":9975},{"a":9976},{"a":9977},{"a":9978},{"a":9979},{"a":9980},{"a":9981},{"a":9982},{"a":9983},{"a":9984},{"a":9985},{"a":9986},{"a":9987},{"a":9988},{"a":9989},{"a":9990},{"a":9991},{"a":9992},{"a":9993},{"a":9994},{"a":9995},{"a":9996},{"a":9997},{"a":9998},{"a":9999}]'

very clear

So I did Before mocha put it into a diff function replace \s. and It's quickening Mocha and fixing bugs.
and..

the result

I fixed it!
in my mocha

const {expect} = require('chai')
const _ = require('lodash')
it('Test failing', function () {
    const longArray = _.times(10000, function (i) {
      return {a : i}
    })
    const shortArray = []
    expect(longArray).deep.equal(shortArray)
})

the test code spend a time like this
real 0m1.657s
user 0m0.878s
sys 0m0.119s

@juergba
Copy link
Member

juergba commented Oct 1, 2019

@wnghdcjfe your PR is difficult to understand.

There are several failing tests in Travis and AppVeyor which show your solution is not working. By filtering all \s you are changing the strings and the diffs are not correct anymore. Your solution may work for objects, but certainly not for strings.

@wnghdcjfe
Copy link
Contributor Author

Thank you for your good reply. Actually, I knew that. I realized after PR, but I'm a little busy right now. About 12 hours later? I'm going to revise it again and PR it

@wnghdcjfe wnghdcjfe closed this Oct 3, 2019
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.

None yet

2 participants