Store compiled regular expressions for #170
This commit is contained in:
+13
-1
@@ -1,4 +1,6 @@
|
||||
<Serializable()>
|
||||
Imports System.Text.RegularExpressions
|
||||
|
||||
<Serializable()>
|
||||
Public Class clsGame
|
||||
Private sGameID As String = Guid.NewGuid.ToString
|
||||
Private sGameName As String = String.Empty
|
||||
@@ -24,6 +26,7 @@ Public Class clsGame
|
||||
Private bRecurseSubFolders As Boolean = True
|
||||
Private oImportTags As New List(Of Tag)
|
||||
Private bImportUpdate As Boolean = False
|
||||
Private oCompiledRegEx As Regex
|
||||
|
||||
<Flags()> Public Enum eOptionalSyncFields
|
||||
None = 0
|
||||
@@ -278,6 +281,15 @@ Public Class clsGame
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Property CompiledRegEx As Regex
|
||||
Get
|
||||
Return oCompiledRegEx
|
||||
End Get
|
||||
Set(value As Regex)
|
||||
oCompiledRegEx = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
ReadOnly Property IncludeArray As String()
|
||||
Get
|
||||
If FileType = String.Empty Then
|
||||
|
||||
@@ -38,6 +38,11 @@ Public Class mgrMonitorList
|
||||
oGame.IsRegEx = CBool(dr("IsRegEx"))
|
||||
oGame.RecurseSubFolders = CBool(dr("RecurseSubFolders"))
|
||||
|
||||
'Compile RegEx
|
||||
If oGame.IsRegEx Then
|
||||
oGame.CompiledRegEx = New Regex(oGame.ProcessName, RegexOptions.Compiled)
|
||||
End If
|
||||
|
||||
Return oGame
|
||||
End Function
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
Imports System.IO
|
||||
Imports System.Management
|
||||
Imports System.Text.RegularExpressions
|
||||
|
||||
Public Class mgrProcessDetection
|
||||
|
||||
@@ -12,7 +11,6 @@ Public Class mgrProcessDetection
|
||||
Private oDuplicateGames As New ArrayList
|
||||
Private bDuplicates As Boolean
|
||||
Private bVerified As Boolean = False
|
||||
Private oRegEx As Regex
|
||||
|
||||
Property FoundProcess As Process
|
||||
Get
|
||||
@@ -144,8 +142,7 @@ Public Class mgrProcessDetection
|
||||
Private Function IsMatch(ByRef oGame As clsGame, ByRef sProcessCheck As String) As Boolean
|
||||
If oGame.IsRegEx Then
|
||||
Try
|
||||
oRegEx = New Regex(oGame.ProcessName)
|
||||
If oRegEx.IsMatch(sProcessCheck) Then
|
||||
If oGame.CompiledRegEx.IsMatch(sProcessCheck) Then
|
||||
Return True
|
||||
End If
|
||||
Catch
|
||||
|
||||
Reference in New Issue
Block a user