summaryrefslogtreecommitdiffstats
path: root/win/C#/Parsing/Parser.cs
diff options
context:
space:
mode:
authorsr55 <[email protected]>2009-12-25 22:24:04 +0000
committersr55 <[email protected]>2009-12-25 22:24:04 +0000
commitfb7fb65d6d57edbf52d7ab7759a36a6034aff0a9 (patch)
tree2dee847f93e4b74394743580ebe96fe2c3ebf69f /win/C#/Parsing/Parser.cs
parentf9470483553d07bfe92219f875db643485d0ace8 (diff)
WinGui:
- Hopefully a significant performance improvement in the Parser ReadLine() Function. This should help when the CLI is throwing out huge amounts of read errors / logging data. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3044 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/Parsing/Parser.cs')
-rw-r--r--win/C#/Parsing/Parser.cs29
1 files changed, 18 insertions, 11 deletions
diff --git a/win/C#/Parsing/Parser.cs b/win/C#/Parsing/Parser.cs
index b3bca0187..ed199ed2a 100644
--- a/win/C#/Parsing/Parser.cs
+++ b/win/C#/Parsing/Parser.cs
@@ -5,6 +5,7 @@
It may be used under the terms of the GNU General Public License. */
using System.IO;
+using System.Text;
using System.Text.RegularExpressions;
using System;
using System.Globalization;
@@ -38,21 +39,21 @@ namespace Handbrake.Parsing
/// <param name="TimeRemaining">The estimated time remaining for this task to complete</param>
public delegate void EncodeProgressEventHandler(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining);
-
+
/// <summary>
/// A simple wrapper around a StreamReader to keep track of the entire output from a cli process
/// </summary>
internal class Parser : StreamReader
{
- private string m_buffer;
+ private StringBuilder _buffer = new StringBuilder("");
/// <summary>
/// The output from the CLI process
/// </summary>
- public string Buffer
+ public String Buffer
{
get
{
- return m_buffer;
+ return _buffer.ToString();
}
}
@@ -82,22 +83,27 @@ namespace Handbrake.Parsing
/// Default constructor for this object
/// </summary>
/// <param name="baseStream">The stream to parse from</param>
- public Parser(Stream baseStream) : base(baseStream)
+ public Parser(Stream baseStream)
+ : base(baseStream)
{
- m_buffer = string.Empty;
}
public override string ReadLine()
{
string tmp = base.ReadLine();
- m_buffer += tmp + Environment.NewLine;
- Match m = Regex.Match(tmp, "^Scanning title ([0-9]*) of ([0-9]*)");
+ _buffer.AppendLine(tmp);
+
+ Match m = null;
+ if (tmp.Contains("Scanning title"))
+ m = Regex.Match(tmp, "^Scanning title ([0-9]*) of ([0-9]*)");
+
if (OnReadLine != null)
OnReadLine(this, tmp);
- if (m.Success && OnScanProgress != null)
- OnScanProgress(this, int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));
+ if (m != null)
+ if (m.Success && OnScanProgress != null)
+ OnScanProgress(this, int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));
return tmp;
}
@@ -106,7 +112,8 @@ namespace Handbrake.Parsing
{
string tmp = base.ReadToEnd();
- m_buffer += tmp + Environment.NewLine;
+ _buffer.AppendLine(tmp);
+
if (OnReadToEnd != null)
OnReadToEnd(this, tmp);