sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    ⚠️ Important | Libfredo 15.6b introduces important bugfixes for Fredo's Extensions Update

    Should we be autoloading?

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 3 Posters 253 Views 3 Watching
    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.
    • thomthomT Offline
      thomthom
      last edited by

      Just thinking out loud here...

      Since the SketchUp Ruby API environment is a shared one - would it not be best practice for us (developers) to use autoload instead of require?

      This would not be feasible with scrambled ruby files as they rely on Sketchup::require - but for all the unscrambled ruby files. The majority is unscrambled. And users have many many plugins installed - often they will use only a fraction of them.

      I'm not expecting a major memory benefit - but I do think that we could expect improvement in SketchUp startup times.

      (Sidenote - I do suspect that toolbar creation is a major component in the startup time. Something that ought to be investigated.)

      Fire at will!

      Thomas Thomassen — SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • A Offline
        Aerilius
        last edited by

        That sounds interesting.
        It's not "thread safe" but I don't think that matters for us.
        Symbols don't support colons, so nested modules would be done like in the comments here: http://www.rubyinside.com/ruby-techniques-revealed-autoload-1652.html

        How much would be the performance gain?
        One could do some testing (I'll do this evening) like plugins normal, plugins disabled, plugins with autoload.

        1 Reply Last reply Reply Quote 0
        • Dan RathbunD Offline
          Dan Rathbun
          last edited by

          I remember trying this a long time ago.. but did not get it working. Maybe I used it wrong?

          As I remember it loads modules, not scripts. So perhaps the name of the script must be the same as the module ?

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            @dan rathbun said:

            I remember trying this a long time ago.. but did not get it working. Maybe I used it wrong?

            I do have it working for a large project I'm working on. I set up some of the mixing modules and base classes to autoload.

            <span class="syntaxdefault"><br />&nbsp;&nbsp;</span><span class="syntaxcomment">#&nbsp;Ensure&nbsp;abstract&nbsp;classes&nbsp;are&nbsp;loaded&nbsp;and&nbsp;found&nbsp;when&nbsp;needed.<br />&nbsp;&nbsp;</span><span class="syntaxdefault">autoload</span><span class="syntaxkeyword">(&nbsp;;</span><span class="syntaxdefault">Observable</span><span class="syntaxkeyword">,&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(&nbsp;</span><span class="syntaxdefault">PATH</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxstring">'observable.rb'&nbsp;</span><span class="syntaxkeyword">)&nbsp;)<br />&nbsp;&nbsp;</span><span class="syntaxdefault">autoload</span><span class="syntaxkeyword">(&nbsp;;</span><span class="syntaxdefault">BezierEntity</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(&nbsp;</span><span class="syntaxdefault">PATH</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxstring">'bezier_entity.rb'&nbsp;</span><span class="syntaxkeyword">)&nbsp;)<br />&nbsp;&nbsp;</span><span class="syntaxdefault">autoload</span><span class="syntaxkeyword">(&nbsp;;</span><span class="syntaxdefault">BezierPatch</span><span class="syntaxkeyword">,&nbsp;&nbsp;</span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(&nbsp;</span><span class="syntaxdefault">PATH</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxstring">'bezier_patch.rb'&nbsp;</span><span class="syntaxkeyword">)&nbsp;)<br />&nbsp;</span><span class="syntaxdefault"></span>
            

            Thomas Thomassen — SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement