HISE Logo Forum
    • Categories
    • Register
    • Login

    reference or Content.getComp....

    Scheduled Pinned Locked Moved Scripting
    5 Posts 2 Posters 259 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ulrikU
      ulrik
      last edited by

      Suppose I have a 200 sliders, 200 buttons 100 panels..etc..
      At several different places in the code, I need to get or set values from some of them
      What is best, is it to declare each one of the components or, in those places where I need the values, just get them with
      Content.getComp...?

      What is best practice? Why?

      Hise Develop branch
      MacOs 15.3.1, Xcode 16.2
      http://musikboden.se

      1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey
        last edited by d.healey

        It kind of depends on exactly what you're doing.

        Generally it's best practice to get references to components up front in on init.

        If you need access them without a const reference then it's best to use Content.getAllComponents() instead of Content.getComponent(). getAllComponents has less overhead because it doesn't need to assign additional memory.

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        ulrikU 1 Reply Last reply Reply Quote 1
        • ulrikU
          ulrik @d.healey
          last edited by

          @d-healey so you're saying that there is no performance or memory difference? Except for the getAllComponents, which is more efficient, less memory demanding?
          I try to use getAllComponents as much as possible

          Hise Develop branch
          MacOs 15.3.1, Xcode 16.2
          http://musikboden.se

          d.healeyD 1 Reply Last reply Reply Quote 0
          • d.healeyD
            d.healey @ulrik
            last edited by

            @ulrik said in reference or Content.getComp....:

            so you're saying that there is no performance or memory difference

            I'm saying there is a difference between getComponent and getAllComponents when you are accessing component properties outside of on init.

            Without knowing exactly what you're wanting to do it's hard to advise the best approach but if it's outside on init and you don't want to create references inside on init you should use getAllComponents().

            Libre Wave - Freedom respecting instruments and effects
            My Patreon - HISE tutorials
            YouTube Channel - Public HISE tutorials

            ulrikU 1 Reply Last reply Reply Quote 1
            • ulrikU
              ulrik @d.healey
              last edited by

              @d-healey thank you!

              Hise Develop branch
              MacOs 15.3.1, Xcode 16.2
              http://musikboden.se

              1 Reply Last reply Reply Quote 0
              • First post
                Last post

              50

              Online

              1.7k

              Users

              11.7k

              Topics

              101.8k

              Posts