Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
rampaa committed Oct 5, 2024
1 parent 9689ff3 commit 5a227bd
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion JL.Core.Tests/LookupTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void LookupText_始まる()
// Arrange
List<LookupResult> expected =
[
new LookupResult
new
(
matchedText: "始まる",
dict: DictUtils.Dicts.Values.First(static dict => dict.Type is DictType.JMdict),
Expand Down
11 changes: 5 additions & 6 deletions JL.Core/Dicts/DictUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,11 @@ internal static Task AutoUpdateBuiltInDicts()
}

Utils.Frontend.Alert(AlertLevel.Information, $"Updating {dict.Type}...");
return dict.Type switch
{
DictType.JMdict => UpdateJmdict(pathExists, true),
DictType.JMnedict => UpdateJmnedict(pathExists, true),
_ => UpdateKanjidic(pathExists, true)
};
return dict.Type is DictType.JMdict
? UpdateJmdict(pathExists, true)
: dict.Type is DictType.JMnedict
? UpdateJmnedict(pathExists, true)
: UpdateKanjidic(pathExists, true);
}

return Task.CompletedTask;
Expand Down
14 changes: 13 additions & 1 deletion JL.Core/Dicts/DictUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,19 @@ dict.Type is DictType.CustomNameDictionary

if (dictDBPaths.Count > 0)
{
DBUtils.DictDBPaths = DBUtils.DictDBPaths.Union(dictDBPaths).ToFrozenDictionary(StringComparer.Ordinal);
Dictionary<string, string> tempDictDBPathDict = new(DBUtils.DictDBPaths.Count + dictDBPaths.Count, StringComparer.Ordinal);

foreach ((string key, string value) in DBUtils.DictDBPaths)
{
tempDictDBPathDict[key] = value;
}

foreach ((string key, string value) in dictDBPaths)
{
tempDictDBPathDict[key] = value;
}

DBUtils.DictDBPaths = tempDictDBPathDict.ToFrozenDictionary(StringComparer.Ordinal);
}

if (tasks.Count > 0 || dictCleared)
Expand Down
14 changes: 13 additions & 1 deletion JL.Core/Freqs/FreqUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,19 @@ public static async Task LoadFrequencies()

if (freqDBPathDict.Count > 0)
{
DBUtils.FreqDBPaths = DBUtils.FreqDBPaths.Union(freqDBPathDict).ToFrozenDictionary(StringComparer.Ordinal);
Dictionary<string, string> tempFreqDBPathDict = new(DBUtils.FreqDBPaths.Count + freqDBPathDict.Count, StringComparer.Ordinal);

foreach ((string key, string value) in DBUtils.FreqDBPaths)
{
tempFreqDBPathDict[key] = value;
}

foreach ((string key, string value) in freqDBPathDict)
{
tempFreqDBPathDict[key] = value;
}

DBUtils.FreqDBPaths = tempFreqDBPathDict.ToFrozenDictionary(StringComparer.Ordinal);
}

if (tasks.Count > 0 || freqCleared)
Expand Down

0 comments on commit 5a227bd

Please sign in to comment.