Sentinel icon indicating copy to clipboard operation
Sentinel copied to clipboard

[Enhancement] Remove repeat check

Open mawen12 opened this issue 10 months ago • 0 comments

Issue Description

Type: enhancement

Describe what feature you want

The class ParamFlowSlot#entry method contains repeat code to check ParamFlowRule exists. It is better to delete first check, because the method checkFlow is responsible for checking the relevant paramters.

class ParamFlowSlot {
    @Override
    public void entry(Context context, ResourceWrapper resourceWrapper, DefaultNode node, int count,
                      boolean prioritized, Object... args) throws Throwable {
        // first check
        if (!ParamFlowRuleManager.hasRules(resourceWrapper.getName())) {
            fireEntry(context, resourceWrapper, node, count, prioritized, args);
            return;
        }

        checkFlow(resourceWrapper, count, args);
        fireEntry(context, resourceWrapper, node, count, prioritized, args);
    }

    void checkFlow(ResourceWrapper resourceWrapper, int count, Object... args) throws BlockException {
        ...

        // second check
        if (!ParamFlowRuleManager.hasRules(resourceWrapper.getName())) {
            return;
        }
        ...
    }
}

Describe your initial design (if present)

The ParamFlowRule only need to be checked once.

Additional context

mawen12 avatar Feb 24 '25 09:02 mawen12