function variantControlVars = getVariantControlVars(modelName, allVarsUsage)
% @Input: modelName and allVarsUsage from Simulink.findvars()
% @Output: Variant control vars unsupported by SLDV

%   Copyright 2021-2022 The MathWorks, Inc.

    variantControlVars = Sldv.utils.findVariantControlVars(modelName);
    
    if ~slavteng('feature','StartupVariantSLDV') || isempty(variantControlVars)
        return;
    end
    
    variantControlVars = removeStartUpVariantParams(variantControlVars, allVarsUsage);
end


function variantControlVars = removeStartUpVariantParams(variantControlVars, allVarsUsage)
    startUpVariantParamNames = Sldv.utils.getStartUpVariantParameters(allVarsUsage);

    if isempty(startUpVariantParamNames)
        return;
    end

    dummyTrueArray = [];
    dummyTrueArray(1:numel(startUpVariantParamNames)) = true;

    % Creating this map for better performance
    startUpVariantParamNameMap = containers.Map(startUpVariantParamNames, dummyTrueArray);

    indicesToRemove = [];
    for idx = 1:numel(variantControlVars)
        if isKey(startUpVariantParamNameMap, variantControlVars(idx).Name)
            indicesToRemove = [indicesToRemove idx]; %#ok<AGROW> 
        end
    end

    variantControlVars(indicesToRemove) = [];
end

