diff --git a/matlab/isoctave.m b/matlab/isoctave.m
index 4117fee6b5827017075ba2c1a7dc7b0c536e135a..890a29d908a1494cc143fdb961d780042f38df65 100644
--- a/matlab/isoctave.m
+++ b/matlab/isoctave.m
@@ -1,6 +1,6 @@
 function A = isoctave()
 
-% Copyright © 2013-2016 Dynare Team
+% Copyright © 2013-2022 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -17,4 +17,6 @@ function A = isoctave()
 % You should have received a copy of the GNU General Public License
 % along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
 
-A = exist('OCTAVE_VERSION');
\ No newline at end of file
+% NB: restricting the search to builtins is important for speed (otherwise it
+% will lookup files, which is slow)
+A = exist('OCTAVE_VERSION', 'builtin');