mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
Refactor dictionary loading in GetTesseract302Dictionaries
Streamlined the loading of dictionaries in the GetTesseract302Dictionaries file by using XmlReader directly on the decompressed stream. This change simplifies the processing flow and reduces the overall amount of coding needed. Signed-off-by: Ivandro Jao <ivandrofly@gmail.com>
This commit is contained in:
parent
06f8d56aeb
commit
6f4e25e022
@ -61,15 +61,12 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
|
||||
{
|
||||
comboBoxDictionaries.Items.Clear();
|
||||
var doc = new XmlDocument();
|
||||
using (var rdr = new StreamReader(stream))
|
||||
using (var zip = new GZipStream(rdr.BaseStream, CompressionMode.Decompress))
|
||||
using (var zip = new GZipStream(stream, CompressionMode.Decompress))
|
||||
using (var reader = XmlReader.Create(zip, new XmlReaderSettings { IgnoreProcessingInstructions = true }))
|
||||
{
|
||||
var data = new byte[195000];
|
||||
var bytesRead = zip.Read(data, 0, data.Length);
|
||||
var s = System.Text.Encoding.UTF8.GetString(data, 0, bytesRead).Trim();
|
||||
try
|
||||
{
|
||||
doc.LoadXml(s);
|
||||
doc.Load(reader);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user