Profile::Set...(std::wstring param) not using std::move #2590

Closed
opened 2026-01-30 22:59:09 +00:00 by claunia · 6 comments
Owner

Originally created by @yves-dolce on GitHub (Jul 5, 2019).

Let me start by saying I did not read the whole source so I might have missed important details.

I was looking at the source code to understand how you're handling the commandline setting and saw that many methods in the Profile class do not move the instance of the std::wstring received and instead create a copy.

Also, why do you mark the methods noexcept when some strings might not be small enough to allow SSO? (e.g. a long command line)

Proposed technical implementation details (optional)

void Profile::SetCommandline(std::wstring cmdline) noexcept
{
    _commandline = std::move(cmdline);
}

Originally created by @yves-dolce on GitHub (Jul 5, 2019). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> Let me start by saying I did not read the whole source so I might have missed important details. I was looking at the source code to understand how you're handling the `commandline` setting and saw that many methods in the `Profile` class do not move the instance of the `std::wstring` received and instead create a copy. Also, why do you mark the methods `noexcept` when some strings might not be small enough to allow SSO? (e.g. a long command line) <!-- A clear and concise description of what the problem is that the new feature would solve. Describe why and how a user would use this new functionality (if applicable). --> # Proposed technical implementation details (optional) ``` void Profile::SetCommandline(std::wstring cmdline) noexcept { _commandline = std::move(cmdline); } ``` <!-- A clear and concise description of what you want to happen. -->
Author
Owner

@zadjii-msft commented on GitHub (Jul 8, 2019):

I'm sure that no one really thought too hard about it - seems like that would work to me.

I'm not sure I know why they're marked noexcept. I bet that we assumed that all the setters in Profile were just simple setters that couldn't possibly throw.

@zadjii-msft commented on GitHub (Jul 8, 2019): I'm sure that no one really thought too hard about it - seems like that would work to me. I'm not sure I know why they're marked noexcept. I bet that we assumed that all the setters in `Profile` were just simple setters that couldn't possibly throw.
Author
Owner

@yves-dolce commented on GitHub (Jul 8, 2019):

If I'm confident you'll take the PR, I can spend time forking and submitting a PR. Just tell me.

@yves-dolce commented on GitHub (Jul 8, 2019): If I'm confident you'll take the PR, I can spend time forking and submitting a PR. Just tell me.
Author
Owner

@DHowett-MSFT commented on GitHub (Jul 8, 2019):

We would definitely take any PR that makes our code better. Thanks 😄

@DHowett-MSFT commented on GitHub (Jul 8, 2019): We would definitely take any PR that makes our code better. Thanks :smile:
Author
Owner

@yves-dolce commented on GitHub (Jul 9, 2019):

OK. So I'm ready to submit it but when I follow the README.MD and call testcon, it ends with:

Summary of TAEF Warnings:
    Warning: TAEF: The test file "......\terminal.fork\bin\x64\Debug\ConHost.Api.Tests.dll" does not exist.
    Warning: TAEF: The test file "file ......\terminal.fork\bin\x64\Debug\ConHost.Resize.Tests.dll" does not exist.
    Warning: TAEF: The test file "file ......\terminal.fork\bin\x64\Debug\ConHost.CJK.Tests.dll" does not exist.

Summary of Non-passing Tests:
    ClipboardTests::CanConvertCharsOutsideKeyboardLayout [Failed]

Summary: Total=1054, Passed=1053, Failed=1, Blocked=0, Not Run=0, Skipped=0

Is this a known issue of the UT?

@yves-dolce commented on GitHub (Jul 9, 2019): OK. So I'm ready to submit it but when I follow the README.MD and call testcon, it ends with: ``` Summary of TAEF Warnings: Warning: TAEF: The test file "......\terminal.fork\bin\x64\Debug\ConHost.Api.Tests.dll" does not exist. Warning: TAEF: The test file "file ......\terminal.fork\bin\x64\Debug\ConHost.Resize.Tests.dll" does not exist. Warning: TAEF: The test file "file ......\terminal.fork\bin\x64\Debug\ConHost.CJK.Tests.dll" does not exist. Summary of Non-passing Tests: ClipboardTests::CanConvertCharsOutsideKeyboardLayout [Failed] Summary: Total=1054, Passed=1053, Failed=1, Blocked=0, Not Run=0, Skipped=0 ``` Is this a known issue of the UT?
Author
Owner

@DHowett-MSFT commented on GitHub (Jul 10, 2019):

I believe so. The UTs might not work if your system codepage is not 1252 😄

@DHowett-MSFT commented on GitHub (Jul 10, 2019): I believe so. The UTs might not work if your system codepage is not 1252 :smile:
Author
Owner

@yves-dolce commented on GitHub (Jul 10, 2019):

Just submitted my first ever Open Source PR #1899 ...

@yves-dolce commented on GitHub (Jul 10, 2019): Just submitted my first ever Open Source PR #1899 ...
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#2590