Skip to content

Commit 090c70b

Browse files
author
BRUNER Patrick
committed
update
1 parent 698d139 commit 090c70b

3 files changed

Lines changed: 14 additions & 81 deletions

File tree

src/LogExpert.UI/Controls/LogWindow/LogWindow.cs

Lines changed: 13 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -3164,7 +3164,7 @@ private void CheckFilterAndHighlight (LogEventArgs e)
31643164

31653165
for (var i = startLine; i < e.LineCount; ++i)
31663166
{
3167-
var line = _logFileReader.GetLogLine(i);
3167+
var line = _logFileReader.GetLogLineMemory(i);
31683168
if (line != null)
31693169
{
31703170
var matchingList = FindMatchingHilightEntries(line);
@@ -3597,25 +3597,22 @@ private static IList<HighlightMatchEntry> MergeHighlightMatchEntries (IList<High
35973597
/// <summary>
35983598
/// Returns the first HighlightEntry that matches the given line
35993599
/// </summary>
3600-
//TODO Replace with ItextvalueMemory
3601-
private HighlightEntry FindHighlightEntry (ITextValue line)
3600+
private HighlightEntry FindHighlightEntry (ITextValueMemory line)
36023601
{
36033602
return FindHighlightEntry(line, false);
36043603
}
36053604

3606-
//TODO Replace with ItextvalueMemory
3607-
private HighlightEntry FindFirstNoWordMatchHighlightEntry (ITextValue line)
3605+
private HighlightEntry FindFirstNoWordMatchHighlightEntry (ITextValueMemory line)
36083606
{
36093607
return FindHighlightEntry(line, true);
36103608
}
36113609

3612-
//TODO Replace with ItextvalueMemory
3613-
private static bool CheckHighlightEntryMatch (HighlightEntry entry, ITextValue column)
3610+
private static bool CheckHighlightEntryMatch (HighlightEntry entry, ITextValueMemory column)
36143611
{
36153612
if (entry.IsRegex)
36163613
{
36173614
//Regex rex = new Regex(entry.SearchText, entry.IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase);
3618-
if (entry.Regex.IsMatch(column.Text))
3615+
if (entry.Regex.IsMatch(column.Text.ToString()))
36193616
{
36203617
return true;
36213618
}
@@ -3624,14 +3621,14 @@ private static bool CheckHighlightEntryMatch (HighlightEntry entry, ITextValue c
36243621
{
36253622
if (entry.IsCaseSensitive)
36263623
{
3627-
if (column.Text.Contains(entry.SearchText, StringComparison.Ordinal))
3624+
if (column.Text.Span.Contains(entry.SearchText.AsSpan(), StringComparison.Ordinal))
36283625
{
36293626
return true;
36303627
}
36313628
}
36323629
else
36333630
{
3634-
if (column.Text.ToUpperInvariant().Contains(entry.SearchText.ToUpperInvariant(), StringComparison.OrdinalIgnoreCase))
3631+
if (column.Text.Span.Contains(entry.SearchText.AsSpan(), StringComparison.OrdinalIgnoreCase))
36353632
{
36363633
return true;
36373634
}
@@ -3644,8 +3641,7 @@ private static bool CheckHighlightEntryMatch (HighlightEntry entry, ITextValue c
36443641
/// <summary>
36453642
/// Returns all HilightEntry entries which matches the given line
36463643
/// </summary>
3647-
//TODO Replace with ItextvalueMemory
3648-
private IList<HighlightEntry> FindMatchingHilightEntries (ITextValue line)
3644+
private IList<HighlightEntry> FindMatchingHilightEntries (ITextValueMemory line)
36493645
{
36503646
IList<HighlightEntry> resultList = [];
36513647
if (line != null)
@@ -3665,14 +3661,13 @@ private IList<HighlightEntry> FindMatchingHilightEntries (ITextValue line)
36653661
return resultList;
36663662
}
36673663

3668-
//TODO Replace with ItextvalueMemory
3669-
private static void GetHighlightEntryMatches (ITextValue line, IList<HighlightEntry> hilightEntryList, IList<HighlightMatchEntry> resultList)
3664+
private static void GetHighlightEntryMatches (ITextValueMemory line, IList<HighlightEntry> hilightEntryList, IList<HighlightMatchEntry> resultList)
36703665
{
36713666
foreach (var entry in hilightEntryList)
36723667
{
36733668
if (entry.IsWordMatch)
36743669
{
3675-
var matches = entry.Regex.Matches(line.Text);
3670+
var matches = entry.Regex.Matches(line.Text.ToString());
36763671
foreach (Match match in matches)
36773672
{
36783673
HighlightMatchEntry me = new()
@@ -4095,7 +4090,7 @@ private void SelectPrevHighlightLine ()
40954090
while (lineNum > 0)
40964091
{
40974092
lineNum--;
4098-
var line = _logFileReader.GetLogLine(lineNum);
4093+
var line = _logFileReader.GetLogLineMemory(lineNum);
40994094
if (line != null)
41004095
{
41014096
var entry = FindHighlightEntry(line);
@@ -4115,7 +4110,7 @@ private void SelectNextHighlightLine ()
41154110
while (lineNum < _logFileReader.LineCount)
41164111
{
41174112
lineNum++;
4118-
var line = _logFileReader.GetLogLine(lineNum);
4113+
var line = _logFileReader.GetLogLineMemory(lineNum);
41194114
if (line != null)
41204115
{
41214116
var entry = FindHighlightEntry(line);
@@ -6557,44 +6552,6 @@ public void OnDataGridViewCellPainting (object sender, DataGridViewCellPaintingE
65576552
/// <param name="line"></param>
65586553
/// <param name="noWordMatches"></param>
65596554
/// <returns></returns>
6560-
public HighlightEntry FindHighlightEntry (ITextValue line, bool noWordMatches)
6561-
{
6562-
// first check the temp entries
6563-
lock (_tempHighlightEntryListLock)
6564-
{
6565-
foreach (var entry in _tempHighlightEntryList)
6566-
{
6567-
if (noWordMatches && entry.IsWordMatch)
6568-
{
6569-
continue;
6570-
}
6571-
6572-
if (CheckHighlightEntryMatch(entry, line))
6573-
{
6574-
return entry;
6575-
}
6576-
}
6577-
}
6578-
6579-
lock (_currentHighlightGroupLock)
6580-
{
6581-
foreach (var entry in _currentHighlightGroup.HighlightEntryList)
6582-
{
6583-
if (noWordMatches && entry.IsWordMatch)
6584-
{
6585-
continue;
6586-
}
6587-
6588-
if (CheckHighlightEntryMatch(entry, line))
6589-
{
6590-
return entry;
6591-
}
6592-
}
6593-
6594-
return null;
6595-
}
6596-
}
6597-
65986555
public HighlightEntry FindHighlightEntry (ITextValueMemory line, bool noWordMatches)
65996556
{
66006557
// first check the temp entries
@@ -6613,6 +6570,7 @@ public HighlightEntry FindHighlightEntry (ITextValueMemory line, bool noWordMatc
66136570
}
66146571
}
66156572
}
6573+
66166574
lock (_currentHighlightGroupLock)
66176575
{
66186576
foreach (var entry in _currentHighlightGroup.HighlightEntryList)
@@ -6632,26 +6590,6 @@ public HighlightEntry FindHighlightEntry (ITextValueMemory line, bool noWordMatc
66326590
}
66336591
}
66346592

6635-
public IList<HighlightMatchEntry> FindHighlightMatches (ITextValue line)
6636-
{
6637-
IList<HighlightMatchEntry> resultList = [];
6638-
6639-
if (line != null)
6640-
{
6641-
lock (_currentHighlightGroupLock)
6642-
{
6643-
GetHighlightEntryMatches(line, _currentHighlightGroup.HighlightEntryList, resultList);
6644-
}
6645-
6646-
lock (_tempHighlightEntryList)
6647-
{
6648-
GetHighlightEntryMatches(line, _tempHighlightEntryList, resultList);
6649-
}
6650-
}
6651-
6652-
return resultList;
6653-
}
6654-
66556593
public IList<HighlightMatchEntry> FindHighlightMatches (ITextValueMemory line)
66566594
{
66576595
IList<HighlightMatchEntry> resultList = [];

src/LogExpert.UI/Entities/PaintHelper.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,9 @@ private static void PaintCell (ILogPaintContextUI logPaintCtx, DataGridViewCellP
330330
[SupportedOSPlatform("windows")]
331331
private static void PaintHighlightedCell (ILogPaintContextUI logPaintCtx, DataGridViewCellPaintingEventArgs e, HighlightEntry groundEntry)
332332
{
333-
//TODO Refactor if possible since Column is ITextValue
334333
var value = e.Value ?? string.Empty;
335334

336-
var matchList = logPaintCtx.FindHighlightMatches(value as ITextValue);
335+
var matchList = logPaintCtx.FindHighlightMatches(value as ITextValueMemory);
337336
// too many entries per line seem to cause problems with the GDI
338337
while (matchList.Count > 50)
339338
{

src/LogExpert.UI/Interface/ILogPaintContextUI.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,8 @@ internal interface ILogPaintContextUI : ILogPaintContext
3333

3434
Bookmark GetBookmarkForLine (int lineNum);
3535

36-
HighlightEntry FindHighlightEntry (ITextValue line, bool noWordMatches);
37-
3836
HighlightEntry FindHighlightEntry (ITextValueMemory line, bool noWordMatches);
3937

40-
IList<HighlightMatchEntry> FindHighlightMatches (ITextValue line);
41-
4238
IList<HighlightMatchEntry> FindHighlightMatches (ITextValueMemory line);
4339

4440
#endregion

0 commit comments

Comments
 (0)