Skip to content

Massive inefficiency + multiple evaluation in bounding box syntaxes #63

@sovdeeth

Description

@sovdeeth

Describe the bug

        return boundingBoxExpression.stream(event).flatMap(boundingBox -> entityDataExpression.stream(event).flatMap(entityData -> {
            Class<? extends Entity> entityClass = entityData.getType();
            Predicate<Entity> filter = entity -> entityClass.isAssignableFrom(entity.getClass());
            return worldExpression.stream(event).flatMap(world -> world.getNearbyEntities(boundingBox, filter).stream());
        })).toArray(Entity[]::new);

can evaluate entitydata and world expression many multiple times, and could call getNearbyEntities many more times than necessary (it's also rather messy code but that's subjective). (ExprBoundingBoxEntities)
I believe this applies to some other bounding box syntaxes too.

To Reproduce
eval EBBE with multiple bounding boxes or entity datas, see that world expression is evaled many times

Expected behavior
only evaluate expressions once

Screenshots
If applicable, add screenshots to help explain your problem.

/sk info:
N/A
Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

Area: Lusk (Skript)Takes place in the 'skript' module. More specifically in the skript implementation.Good First IssueGood for newcomersPriority: MediumShould be addressed decently soon,Status: PlannedPlanned for implementation. Not waiting on other features or changes to be implemented.Type: BugSomething isn't working

Projects

Status

Accepted

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions