Giter Site home page Giter Site logo

Comments (2)

martinothamar avatar martinothamar commented on May 9, 2024

Good catch! If I understand this issue correct, defensive copies are made during use (access properties etc), while by removing the in parameter a copy is also made. Can we avoid these issues by using ref instead of in on the wrapper? I think I should make some benchmarks for this to see exactly what the behavior is here. I tried to see the codegen difference for this in sharplab a while ago but was unable to produce the difference. I might be misunderstanding something here..

from mediator.

Tornhoof avatar Tornhoof commented on May 9, 2024

Yes you can use ref, but it should not be necessary.
The jit is smart enough by now, see
https://sharplab.io/#v2:EYLgxg9gTgpgtADwGwBYA0AXEBDAzgWwB8ABAJgEYBYAKGIAYACY8gOgCUBXAOwwEt8YLAMIR8AB14AbGFADKMgG68wMXAG4aNYgGYmpBkIYBvGgzMNY2ACYQukgJ4NcGKBzAYGAEWwZsx0+aBOhYw1rYODLw8DAhoDPZxAF5xAO4a1IGBANoAsjAYABYQVgCS4pIAFHmFxWVikgDyYny2uCwAchAldlFRAOYAlAC6AZlMupY2do7EKAwAQthQFQPGDAC+oxtbW8xITHMAKqoY5BXevgxWqyYZY5EAZgwVViwIDAB8DHSrr4vLA3SgU2dzMewODGOzlIFSiXh8fmu/lBmV4Txeb0+31+LH+KyB5hB6yAA===

The asm for both methods, with and without in, is the same for a read-only struct. Even if the struct is only defacto read-only, by making all fields and methods read-only it's smart enough.

That's why I said in the PR that we can let the jit decide.

from mediator.

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.