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

[Performance] Avoid unnecessary predicate allocations in RecyclePool.TryGetElementCore #15806

Open
Tracked by #8597
Youssef1313 opened this issue Mar 8, 2024 · 0 comments
Labels
area/performance 📈 Categorizes an issue or PR as relevant to performance difficulty/starter 🚀 Categorizes an issue for which the difficulty level is reachable by newcomers good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/enhancement New feature or request

Comments

@Youssef1313
Copy link
Member

What would you like to be added

image

A simple loop instead of FindIndex will be more efficient.

Alternatively, introduce a FindIndex extension method like:

public int FindIndex(this List<T> list, TState state, Func<T, TState, bool> match)
{
  for (int i = 0; i < list.Count; i++)
  {
      if (match(list[i], state)) return i;
  }
  return -1;
}

// caller:
// elements.FindIndex(winrtOwner, (elemInfo, winrtOwner) => elemInfo.Owner == winrtOwner || elemInfo.Owner == null)

Why is this needed

No response

For which platform

No response

Anything else we need to know?

No response

@Youssef1313 Youssef1313 added kind/enhancement New feature or request help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. triage/untriaged Indicates an issue requires triaging or verification difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. area/performance 📈 Categorizes an issue or PR as relevant to performance labels Mar 8, 2024
@MartinZikmund MartinZikmund added difficulty/starter 🚀 Categorizes an issue for which the difficulty level is reachable by newcomers and removed triage/untriaged Indicates an issue requires triaging or verification difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. labels Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/performance 📈 Categorizes an issue or PR as relevant to performance difficulty/starter 🚀 Categorizes an issue for which the difficulty level is reachable by newcomers good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants