@@ -55,6 +55,7 @@ internal sealed class GroupPanel
5555 private string ? _publicSyncshellAliasToJoin ;
5656 private readonly ConcurrentDictionary < string , GroupCommunityDto > _communityCache = new ( StringComparer . Ordinal ) ;
5757 private readonly ConcurrentDictionary < string , bool > _communityLoading = new ( StringComparer . Ordinal ) ;
58+ private readonly Dictionary < string , DrawGroupPair > _groupPairRowCache = new ( StringComparer . Ordinal ) ;
5859
5960 public GroupPanel ( SnowMediator mediator , ApiController apiController , DalamudUtilService dalamudUtilService , PairManager pairManager ,
6061 UidDisplayHandler uidDisplayHandler , SnowcloakConfigService snowcloakConfig , NotesStore notesStore , ShellConfigStore shellConfigStore ,
@@ -579,13 +580,7 @@ private void DrawSyncshell(GroupFullInfoDto groupDto, List<Pair> pairsInGroup)
579580 continue ;
580581 }
581582
582- var drawPair = new DrawGroupPair (
583- groupDto . GID + pair . UserData . UID , pair ,
584- ApiController , _mediator , groupDto ,
585- groupPairInfo ,
586- _uidDisplayHandler ,
587- _charaDataManager ,
588- _snowcloakConfig ) ;
583+ var drawPair = GetGroupPairRow ( groupDto , pair , groupPairInfo ) ;
589584
590585 bool pausedByYou ;
591586 bool pausedByOther ;
@@ -654,6 +649,28 @@ private void DrawSyncshell(GroupFullInfoDto groupDto, List<Pair> pairsInGroup)
654649 ImGui . Unindent ( 20 ) ;
655650 }
656651
652+ private DrawGroupPair GetGroupPairRow ( GroupFullInfoDto groupDto , Pair pair , GroupPairFullInfoDto groupPairInfo )
653+ {
654+ var id = groupDto . GID + pair . UserData . UID ;
655+ if ( ! _groupPairRowCache . TryGetValue ( id , out var row )
656+ || ! ReferenceEquals ( row . Pair , pair )
657+ || ! ReferenceEquals ( row . Group , groupDto )
658+ || ! ReferenceEquals ( row . GroupPairInfo , groupPairInfo ) )
659+ {
660+ row = new DrawGroupPair ( id , pair , ApiController , _mediator , groupDto , groupPairInfo ,
661+ _uidDisplayHandler , _charaDataManager , _snowcloakConfig ) ;
662+ _groupPairRowCache [ id ] = row ;
663+ }
664+
665+ return row ;
666+ }
667+
668+ private void PruneGroupPairRowCache ( int activeEntryCount )
669+ {
670+ if ( _groupPairRowCache . Count > activeEntryCount * 4 + 64 )
671+ _groupPairRowCache . Clear ( ) ;
672+ }
673+
657674 private void DrawGroupCommunity ( GroupFullInfoDto groupDto )
658675 {
659676 var community = GetCommunity ( groupDto ) ;
@@ -1066,15 +1083,17 @@ private void DrawSyncShellButtons(GroupFullInfoDto groupDto, List<Pair> groupPai
10661083 private void DrawSyncshellList ( float contentWidth , float ySize )
10671084 {
10681085 ImGui . BeginChild ( "list" , new Vector2 ( contentWidth , ySize ) , border : false ) ;
1086+ var groups = _pairManager . GroupPairs . OrderBy ( g => g . Key . Group . AliasOrGID , StringComparer . OrdinalIgnoreCase ) . ToList ( ) ;
10691087 using ( ImRaii . PushStyle ( ImGuiStyleVar . FramePadding , new Vector2 ( ImGui . GetStyle ( ) . FramePadding . X , 7f * ImGuiHelpers . GlobalScale ) ) )
10701088 using ( ImRaii . PushStyle ( ImGuiStyleVar . ItemSpacing , new Vector2 ( ImGui . GetStyle ( ) . ItemSpacing . X , 2f * ImGuiHelpers . GlobalScale ) ) )
10711089 {
1072- foreach ( var entry in _pairManager . GroupPairs . OrderBy ( g => g . Key . Group . AliasOrGID , StringComparer . OrdinalIgnoreCase ) . ToList ( ) )
1090+ foreach ( var entry in groups )
10731091 {
10741092 using ( ImRaii . PushId ( entry . Key . Group . GID ) ) DrawSyncshell ( entry . Key , entry . Value ) ;
10751093 }
10761094 }
10771095 ImGui . EndChild ( ) ;
1096+ PruneGroupPairRowCache ( groups . Sum ( g => g . Value . Count ) ) ;
10781097 }
10791098
10801099}
0 commit comments