mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-04-24 23:57:12 -05:00
One less allocation
compiler can infer correct string concat size both ways
This commit is contained in:
parent
9da0955f10
commit
018694b84f
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
|
|
@ -82,7 +83,8 @@ private static IEnumerable<ComboItem> GetFilteredMoves(IGameValueLimit limit, Ga
|
|||
var legal = source.LegalMoveDataSource;
|
||||
return limit switch
|
||||
{
|
||||
SAV7b or PB7 => legal.Where(s => MoveInfo7b.IsAllowedMoveGG((ushort)s.Value)), // LGPE: Not all moves are available
|
||||
// LGPE: Not all moves are available
|
||||
SAV7b or PB7 => legal.Where(s => MoveInfo7b.IsAllowedMoveGG((ushort)s.Value)),
|
||||
_ => legal.Where(m => m.Value <= limit.MaxMoveID),
|
||||
};
|
||||
}
|
||||
|
|
@ -111,16 +113,17 @@ public IReadOnlyList<ComboItem> GetAbilityList(IPersonalAbility pi)
|
|||
var list = new ComboItem[pi.AbilityCount];
|
||||
|
||||
var alist = Source.Strings.Ability;
|
||||
var suffix = AbilityIndexSuffixes;
|
||||
var suffixes = AbilityIndexSuffixes;
|
||||
for (int i = 0; i < list.Length; i++)
|
||||
{
|
||||
var ability = pi.GetAbilityAtIndex(i);
|
||||
var display = alist[ability] + suffix[i];
|
||||
var suffix = suffixes[i];
|
||||
var display = $"{alist[ability]} ({suffix})";
|
||||
list[i] = new ComboItem(display, ability);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private static readonly string[] AbilityIndexSuffixes = [" (1)", " (2)", " (H)"];
|
||||
private static ReadOnlySpan<char> AbilityIndexSuffixes => ['1', '2', 'H'];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user