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

Discard empty command histories before discarding LRU non-empty ones #13869

Merged
2 commits merged into from
Aug 31, 2022

Conversation

serd2011
Copy link
Contributor

@serd2011 serd2011 commented Aug 29, 2022

When selecting candidate history, priority is given to histories with empty commands list.

I think lazily calling s_Allocate will require a ton of rewriting. Also I think it is not an unexpended behavior that buffer is allocated when an application connects.

Closes #13571

@ghost ghost added Area-CookedRead The cmd.exe COOKED_READ handling Issue-Task It's a feature request, but it doesn't really need a major design. Product-Conhost For issues in the Console codebase labels Aug 29, 2022
@github-actions

This comment has been minimized.

Copy link
Member

@lhecker lhecker left a comment

Choose a reason for hiding this comment

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

I get the feeling that there's some way to write this without the need for 3 OR'd conditions... Something like this (pseudocode)?

const auto beg = s_historyLists.crbegin();
const auto end = s_historyLists.crend();

auto candidate = std::find_if(beg, end, [](const auto& it) {
    return WI_IsFlagClear(it.Flags, CLE_ALLOCATED);
});

const auto optimalCandidate = std::find_if(candidate, end, [](const auto& it) {
    return WI_IsFlagClear(it.Flags, CLE_ALLOCATED) && it._commands.empty();
});
if (optimalCandidate != end)
{
    candidate = optimalCandidate;
}

if (candidate != end)
{
    s_historyLists.erase(std::next(it).base());
}

...but I'm not convinced that this is an improvement.

@DHowett DHowett changed the title Command History discards empty histories first before discarding LRU non-empty history Discard empty command histories first before discarding LRU non-empty history Aug 31, 2022
@DHowett DHowett changed the title Discard empty command histories first before discarding LRU non-empty history Discard empty command histories first before discarding a non-empty one Aug 31, 2022
@DHowett
Copy link
Member

DHowett commented Aug 31, 2022

Thanks for implementing this! I reworded it slightly so that GitHub didn't "wrap" the title once it committed it. 😄

@DHowett DHowett changed the title Discard empty command histories first before discarding a non-empty one Discard empty command histories before discarding LRU non-empty ones Aug 31, 2022
@DHowett DHowett added the AutoMerge Marked for automatic merge by the bot when requirements are met label Aug 31, 2022
@ghost
Copy link

ghost commented Aug 31, 2022

Hello @DHowett!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit cbbd1e8 into microsoft:main Aug 31, 2022
@ghost
Copy link

ghost commented Sep 13, 2022

🎉Windows Terminal Preview v1.16.252 has been released which incorporates this pull request.:tada:

Handy links:

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-CookedRead The cmd.exe COOKED_READ handling AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Task It's a feature request, but it doesn't really need a major design. Product-Conhost For issues in the Console codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Command History should discard empty histories first before discarding LRU non-empty history
3 participants