GithubHelp home page GithubHelp logo

Comments (14)

palemieux avatar palemieux commented on July 22, 2024

Is it on all for...in loops, including those over arrays?

Would replacing for...in with for (var i = 0; i < a.length; i++) solve the issue?

from imscjs.

xoundboy avatar xoundboy commented on July 22, 2024

Yes it seems to be all for...in loops, including arrays, although I didn't test every instance of for...in in the whole library.

replacing for...in with for (var i = 0; i < a.length; i++) should solve the issue. I'll check today and leave an update later. Thanks

from imscjs.

nigelmegitt avatar nigelmegitt commented on July 22, 2024

We've noticed something similar and have a pull request on our BBC fork at bbc#9 to address this issue, which may help.

It's also worth noting that replacing the for ... in loops with indexed-based array iterators should provide a performance improvement too: I haven't got any profiling results that demonstrate this for our real world content, unfortunately.

from imscjs.

xoundboy avatar xoundboy commented on July 22, 2024

I was thinking the very same thing about potentially improving performance by avoiding any hasOwnProperty checks which I believe slow things down, although I don't have any data to prove that either, just a hunch :-) Anyway, thanks for your comment. Good to know it's not just me that has this problem. Maybe it would make sense to fix this upstream and then rebase the changes into your fork @nigelmegitt

from imscjs.

nigelmegitt avatar nigelmegitt commented on July 22, 2024

@xoundboy yes, for sure where we have improvements it's our intention to push them upstream (or fetch them from upstream if others have already done the same) to minimise the deltas between our fork and the main repo. We have some divergence that's required for us to deal with specifics of our environment.

from imscjs.

nigelmegitt avatar nigelmegitt commented on July 22, 2024

potentially improving performance by avoiding any hasOwnProperty

Just for clarity, the performance improvements don't come from this, but from changing to indexed based array iterator for loops rather than for ... in.

I don't know a way to avoid using hasOwnProperty.

from imscjs.

palemieux avatar palemieux commented on July 22, 2024

replacing for...in with for (var i = 0; i < a.length; i++) should solve the issue. I'll check today and leave an update later. Thanks

Great. Looking forward to it.

from imscjs.

xoundboy avatar xoundboy commented on July 22, 2024

@palemieux I verified that for (var i = 0; i < a.length; i++) solves the problem. Please go ahead and replace the for...in loops, or let me know if you would like me to prepare a PR. Thank you.

from imscjs.

palemieux avatar palemieux commented on July 22, 2024

let me know if you would like me to prepare a PR.

That would be great!

from imscjs.

xoundboy avatar xoundboy commented on July 22, 2024

OK, I've got a branch ready called issues/0209-guard-against-native-prototype-property-iteration (trying to copy your branch naming scheme). Please grant me access to push to the repo. Thanks. @palemieux

from imscjs.

palemieux avatar palemieux commented on July 22, 2024

Please grant me access to push to the repo. Thanks.

Even better, any chance you might be able to create the branch on a fork of the repo in your github account?

This is the intended Github workflow AFAIK.

from imscjs.

xoundboy avatar xoundboy commented on July 22, 2024

@palemieux This is the first time I'm making a PR in Github using this workflow. Thanks for the guidance. Here's the PR: #210 - it includes some whitespace changes which I didn't notice until too late. Let me know if you need me to revert those.

from imscjs.

palemieux avatar palemieux commented on July 22, 2024

This is the first time I'm making a PR in Github using this workflow.

Super! Thanks.

Let me know if you need me to revert those.

Not fatal... just distracting. How difficult is it to revert them?

from imscjs.

xoundboy avatar xoundboy commented on July 22, 2024

It's a real pain to revert them. I'd really prefer not to if possible :)

from imscjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.