Skip to content

Use new string.Split() overloads - #11867

Merged
Ilya (iSazonov) merged 3 commits into
PowerShell:masterfrom
iSazonov:use-split-new
Mar 13, 2020
Merged

Ilya (iSazonov) merged 3 commits into
PowerShell:masterfrom
iSazonov:use-split-new

Conversation

@iSazonov

@iSazonov Ilya (iSazonov) commented Feb 17, 2020 •

Copy link
Copy Markdown
Collaborator

PR Summary

Use new String.Split overlods to remove extra allocations.

PR Context

PR Checklist

@iSazonov Ilya (iSazonov) added the CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log label Feb 17, 2020
@iSazonov Ilya (iSazonov) added this to the 7.1.0-preview.1 milestone Feb 17, 2020

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this a LINQ usage now? I think it's probably best to keep it as a string

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

But if it's not LINQ, then no issues

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

No, it is String method:

public bool Contains(char value);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ok, looks good

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Might be worth labelling the 2 parameter

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems like this can be just reduced to .Trim('"')?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
object[] modulesToImport = optionValue.Split(",", StringSplitOptions.RemoveEmptyEntries);
object[] modulesToImport = optionValue.Split(',', StringSplitOptions.RemoveEmptyEntries);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

@ghost ghost added Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept and removed Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept labels Feb 19, 2020
@iSazonov

Copy link
Copy Markdown
Collaborator Author

PoshChan-Bot (@PoshChan) Please retry linux

@PoshChan

Copy link
Copy Markdown
Collaborator

Ilya (@iSazonov), successfully started retry of PowerShell-CI-Linux

@SteveL-MSFT Steve Lee (SteveL-MSFT) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@iSazonov
Ilya (iSazonov) merged commit 2e8ced4 into PowerShell:master Mar 13, 2020
@iSazonov
Ilya (iSazonov) deleted the use-split-new branch March 13, 2020 12:46
@ghost

Copy link
Copy Markdown

🎉v7.1.0-preview.1 has been released which incorporates this pull request.:tada:

Handy links:

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants