
A common complaint.
Not likely an issue but "AmbientOcclusionProLoader.rb" has a comment at the top, viz:
#AmbientOcclusionProCore.rb
The “loader” file is actually require’d by "AmbientOcclusionProCore.rb""
The "AmbientOcclusionProLoader.rb" file is strange in that it’s very busy with many large literal path strings and if clauses that looked to have been switched off by adding and false.
Here for what it’s worth is a more dynamic loader file, as an example, etc.
AmbientOcclusionProLoader_dynamic.rb (1.4 KB)
I don’t think your extension registrar file needs that DummyLanguageHandler anymore if you are not supporting SketchUp versions under 14 (and it looks like only v17+.)
Your "AmbientOcclusionPro.rb" file has an issue. It repeatedly (from quite a few UI::Command procs,) calls an #init method, which will call Kernel#require with a large string argument. This is done apparently to be sure the compiled code is loaded.
But each time this is called, the very large global $LOADED_FEATURES array must be iterated and each member path string checked for a match to this argument path string. Ruby String comparison is quite slow, so this method of checking if your resource is loaded is inefficient.
Ie …
module AmbientOcclusionPro
def self.init()
require 'AmbientOcclusionPro/AmbientOcclusionProLoader.rb'
end
You could set a boolean @core_loaded variable to true after the binaries are loaded, and thereafter check this before calling #init …
… or, even better, if your binaries define any methods, you could simply ask the module if it responds_to?(:some_method_name)
For example, I see that there is reference to a "initAPI" method that is not defined in Ruby.
This (or a similar method defined in C) could be used as a loaded test. Ie …
module AmbientOcclusionPro
def self.init()
return if self.respond_to?(:initAPI)
require 'AmbientOcclusionPro/AmbientOcclusionProLoader.rb'
end
In this way you can avoid the needless path string checking once the binaries are loaded.