Skip to content

Optimization: extensive null checks #135

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

zbyszekprasak
Copy link

Collection constructor is called from two places: implicit conversion from list of error and from array of errors. I have noticed that implicit conversion from array of errors has its own null check so effectively it is done twice. I have added null check in implicit conversion from list of errors and removed one from constructor. Additionally I have fixed inaccurate array converter description and moved Value constructor at the top of constructor block.

Contains #128

kebrok and others added 3 commits November 20, 2024 01:13
…vate ErrorOr(List<Error> errors)

private ErrorOr(List<Error> errors)
{
	if (errors is null)
	{
		throw new ArgumentNullException(nameof(errors));
	}

	if (errors is null || errors.Count == 0)
	{
		throw new ArgumentException("Cannot create an ErrorOr<TValue> from an empty collection of errors. Provide at least one error.", nameof(errors));
	}

	_errors = errors;
}

This check is unnecessary due to the one performed just above.
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

Successfully merging this pull request may close these issues.

2 participants