帮忙优化一段代码        private string ConvertBuffRecordsToString(List<BuffRecord> buffRecords)
        {
            StringBuilder sb = new StringBuilder();
            
            var keywords = GameConfiguration.keywordsInfo.keywords;
            
            foreach (var record in buffRecords)
            {
                if (record.keywordTypes.Count > 0)
                {
                    for (int i = 0; i < record.keywordTypes.Count; i++)
                    {
                        CardKeyWordType keyWordType = record.keywordTypes[i];
                        
                        if (buffKeyWordDic.TryGetValue(keyWordType, out string keywordName))
                        {
                            if (i == 0)
                            {
                                sb.AppendLine($"{record.buffName}: {keywordName}"); 
                            }
                            else
                            {
                                sb.Append($", {keywordName}");
                            }
                        }
                        else
                        {
                            // 从keywords列表中查找与record.keywordType匹配的KeywordInfo
                            var keywordInfo = keywords.Find(k => k.keywordType == keyWordType);
                            // 使用找到的name替换原来的keywordType
                            if (keywordInfo != null)
                            {
                                if (i == 0)
                                {
                                    sb.AppendLine($"{record.buffName}: {keywordInfo.name}"); 
                                }
                                else
                                {
                                    sb.Append($", {keywordInfo.name}");
                                }
                                buffKeyWordDic.Add(keyWordType, keywordInfo.name);
                            }
                            else
                            {
                                if (i == 0)
                                {
                                    sb.AppendLine($"{record.buffName}: {keyWordType}"); 
                                }
                                else
                                {
                                    sb.Append($", {keyWordType}");
                                }
                                buffKeyWordDic.Add(keyWordType, keyWordType.ToString());
                            }
                        } 
                    }
                }
                else
                {
                    sb.AppendLine($"{record.buffName}: ");
                }

                if (!record.attack.Equals( GameAttribute.Zero))
                {
                    if (record.attack > GameAttribute.Zero)
                    {
                        sb.Append($"+{record.attack.Value.intValue}");
                    }                    
                    else
                    {
                        sb.Append($"{record.attack.Value.intValue}");
                    }
                }
                if (!record.health.Equals( GameAttribute.Zero))
                {
                    if (record.health > GameAttribute.Zero)
                    {
                        sb.Append($"/+{record.health.Value.intValue}");
                    }
                    else
                    {
                        sb.Append($"/{record.health.Value.intValue}");
                    }
                }
            }
        
            return sb.ToString();
        }