You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, Zeffiro Interface makes extensive use of the Matlab function eval, where it is not needed. As an example, suppose we had a struct named zef in our current workspace/symbol table. The code then does things like
if eval('zef.use_gpu')
% Initialize a bunch of gpuArraysend
instead of just
ifzef.use_gpu% Initialize a bunch of gpuArraysend
to determine whether a GPU can be utilized in computations. The latter option is the sensible one, as it skips an additional (unnecessary) call to the Matlab parser, making it the faster option.
Steps to reproduce
Navigate to the Zeffiro Interface installation folder with cd /path/to/zeffiro_interface/,
make the function call utilities.lint_mfiles("m") and/or utilities.lint_mfiles("plugins") and
observe the EVLDOT warnings in the function output to see where eval is being used unnecessarily.
Expected behavior
There should be no calls to eval, unless absolutely necessary. It is only a shortcut for building variable names dynamically, but even that use-case can be replaced with the use of dynamic field names.
Example output of utilities.lint_mfiles
Found unacceptable linter message in /Users/soderhos/zeffiro_interface/m/mesh/zef_process_meshes.m:
ID: EVLDOT
Severity: warning
On line: 321
Description: 'eval' is inefficient and makes code less clear. Use dynamic field names to access structure fields or object properties instead.
Error using utilities.lint_mfiles
Description
Currently, Zeffiro Interface makes extensive use of the Matlab function
eval
, where it is not needed. As an example, suppose we had astruct
namedzef
in our current workspace/symbol table. The code then does things likeinstead of just
to determine whether a GPU can be utilized in computations. The latter option is the sensible one, as it skips an additional (unnecessary) call to the Matlab parser, making it the faster option.
Steps to reproduce
cd /path/to/zeffiro_interface/
,utilities.lint_mfiles("m")
and/orutilities.lint_mfiles("plugins")
andEVLDOT
warnings in the function output to see whereeval
is being used unnecessarily.Expected behavior
There should be no calls to
eval
, unless absolutely necessary. It is only a shortcut for building variable names dynamically, but even that use-case can be replaced with the use of dynamic field names.Example output of utilities.lint_mfiles
Context
Remark
This issue could be fixed at least partly by running the following
fish
script in the Zeffiro Interface installation folder:Here
ggrep
is GNU's version of the programgrep
andgsed
is GNU's version ofsed
.The text was updated successfully, but these errors were encountered: