From 771c7f8e0b30bc7951ddf14e600beb225b2b8546 Mon Sep 17 00:00:00 2001 From: Nuno Guedelha Date: Mon, 15 Jun 2020 15:35:00 +0200 Subject: [PATCH] Improved compilation time of WBToolbox blocks by optimizing the `Blockinitialization()` code. - Refer to https://github.com/robotology/wb-toolbox/issues/189 for full details. - In `Blockinitialization()` current implementation, we first retrieve the list of all the WBT blocks in the model. Then we look for the closest Config block, starting from the block's scope, and going up in the tree. - The optimization consisted in retrieving only the Config blocks (name under mask is `ImConfig`) instead of the full list. the reduced list is enough for the second regexp, when looking for the closest Config, since only the lines containing `ImConfig` are supposed to match the regexp. - This change is compatible with the support of multi-config models. --- matlab/+WBToolbox/BlockInitialization.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/matlab/+WBToolbox/BlockInitialization.m b/matlab/+WBToolbox/BlockInitialization.m index 875fee888..751ce8fba 100644 --- a/matlab/+WBToolbox/BlockInitialization.m +++ b/matlab/+WBToolbox/BlockInitialization.m @@ -16,8 +16,8 @@ blockNameSplit = strsplit(currentBlock,'/'); topLevel = blockNameSplit{1}; - % Get all the blocks from the top level of the system - blocks_system = find_system(topLevel,'LookUnderMasks','on','FollowLinks','on'); + % Get all the "Config" blocks from the top level of the system (name of block under mask matching 'ImConfig') + blocks_system = find_system(topLevel,'LookUnderMasks','on','FollowLinks','on','Regexp','on','Name','ImConfig'); % Get the name of the block's subsystem %[blockScopeName,~] = fileparts(blockAbsoluteName);