Giter Club home page Giter Club logo

Comments (6)

andreaslennartz avatar andreaslennartz commented on August 17, 2024 1

@JR-Morgan
Sure, just created a PR for you dev branch.

from speckle-sharp.

JR-Morgan avatar JR-Morgan commented on August 17, 2024

🤔 I think you're right, something's a bit fishy with this if block.

I wonder if we could remove the ContainsKey check all together, and simply use Converted[appId] = conversionResult;
@connorivy what do you think?

from speckle-sharp.

andreaslennartz avatar andreaslennartz commented on August 17, 2024

Thanks for looking into this.

Not quite sure if this helps, but after changing the code block to this:

if (dict.ContainsKey)
  dict[key] = value;
else 
  dict.Add(key, value)

my Revit project which I use for testing is converted much faster as before (because no exceptions are thrown, which added quite a lot of overhead to execution time).
Also, both parts of the if/else blocks are hit during debugging, so the logic does either add or change values.
Also, when the method is hit in my tests for the first, the dictionary itself is empty, so assignments won't work until some keys are added.

But I don't understand what the method is supposed to do at all, or what it's purpose is. Just thought I add this here to support you guys somehow.

from speckle-sharp.

JR-Morgan avatar JR-Morgan commented on August 17, 2024

If you change your code snippet to just:

dict[key] = value;

with no if check atall, does this still work for you?

from speckle-sharp.

andreaslennartz avatar andreaslennartz commented on August 17, 2024

@JR-Morgan
Sorry, my fault.
I was so used to writing the "if not contains key, then add, else assing" pattern in my own code, that I oversaw that the dictionary already has this build in when you assign a key directly as you proposed.
You are right, this will also work, sorry for the confusion.

from speckle-sharp.

JR-Morgan avatar JR-Morgan commented on August 17, 2024

No worries, I think we made the same mistake here.

Would you be comfortable submitting a PR to this repo with the same change?

from speckle-sharp.

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.