Skip to content

Conversation

@nerfZael
Copy link
Contributor

@nerfZael nerfZael commented Oct 26, 2022

Closes #1378

@nerfZael nerfZael changed the title CLI config refactor Config builder and CLI config refactor Oct 28, 2022
@nerfZael nerfZael marked this pull request as ready for review October 28, 2022 11:37
Comment on lines +174 to +178
const idx = this.config.envs.findIndex((x) => Uri.equals(x.uri, envUri));

if (idx > -1) {
this.config.envs.splice(idx, 1);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: wouldn't it be easier to just use filter here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this comment can be applied to all the remove* that uses this logic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't written this code, but I suspect it's a bit faster than using filter since the arrays are always unique.
I'm fine with either solution
cc @pileks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, having a Set would be the fastest. I belive the loading will also be easier

Comment on lines +174 to +178
const idx = this.config.envs.findIndex((x) => Uri.equals(x.uri, envUri));

if (idx > -1) {
this.config.envs.splice(idx, 1);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, having a Set would be the fastest. I belive the loading will also be easier

return this;
}

addRedirect(from: Uri | string, to: Uri | string): ClientConfigBuilder {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about having redirects as a map instead of a list of from-to?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We talked about making envs a map, but yea, redirects could also make sense. I think the same applies to wrappers and packages.
I'll look into the best way to do that in a follow-up PR

Comment on lines +229 to +234
addInterfaceImplementations(
interfaceUri: Uri | string,
implementationUris: Array<Uri | string>
): ClientConfigBuilder {
const interfaceUriSanitized = Uri.from(interfaceUri);
const implementationUrisSanitized = implementationUris.map(Uri.from);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can also represented as map to simplify things

@nerfZael nerfZael requested a review from pileks as a code owner November 2, 2022 16:12
@pileks pileks merged commit b2b196a into origin-0.10-dev Nov 2, 2022
@dOrgJelli dOrgJelli deleted the nerfzael-cli-config-refactoring branch April 10, 2023 17:02
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.

Config builder and CLI config refactor

6 participants