Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FhirPath expression node constructors should call its IEnumerable args only once #1128

Closed
ewoutkramer opened this issue Sep 27, 2019 · 3 comments
Assignees

Comments

@ewoutkramer
Copy link
Member

ewoutkramer commented Sep 27, 2019

If you look at this code from ExpressionNode.cs in the fhirpath engine:

        public FunctionCallExpression(Expression focus, string name, TypeSpecifier type, IEnumerable<Expression> arguments, ISourcePositionInfo location = null) : base(type, location)
        {
            if (string.IsNullOrEmpty(name)) throw Error.ArgumentNull("name");
            Focus = focus;
            FunctionName = name;
            Arguments = arguments ?? throw Error.ArgumentNull("arguments");
        }

We see that the IEnumerable arguments is stored in Arguments. Whenever a visitor passes over this node and uses Argument multiple times, IEnumerable is evaluated over and over again, possibily triggering expensive re-visiting of the expression passed into the argument.

We should change Arguments to an array, and call ToArray() once in the constructor.

@en-gstoian en-gstoian self-assigned this Oct 18, 2019
@marcovisserFurore
Copy link
Member

@gstoian: I see that you are done developing, but is there also a pull request of this issue?

@brianpos
Copy link
Collaborator

Can you include me on the PR review? As wanting to check what this to array is in.
For things like large codesystems or lists it can be super expensive if not required...

@en-gstoian
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants