Skip to content

Commit 49bff5d

Browse files
committed
removed the annoying and pointless setTimeout
1 parent 3038a07 commit 49bff5d

File tree

1 file changed

+23
-27
lines changed

1 file changed

+23
-27
lines changed

lib/node-xml.js

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -807,37 +807,33 @@ SaxParser.prototype.parseFile = function(filename) { //This function will only w
807807
SaxParser.prototype.parseString = function(strD) {
808808
util = require('util');
809809
var that = this;
810+
var startnew = true;
811+
if(!that.m_parser){
812+
that.m_parser = new XMLP(strD);
813+
startnew = false;
814+
}
815+
else{
816+
that.m_parser.continueParsing(strD);
817+
startnew = true;
818+
}
810819

811-
setTimeout(function(){
812-
var startnew = true;
813-
if(!that.m_parser){
814-
that.m_parser = new XMLP(strD);
815-
startnew = false;
816-
}
817-
else{
818-
that.m_parser.continueParsing(strD);
819-
startnew = true;
820-
}
821-
822-
//if(that.m_hndDoc && that.m_hndDoc.setDocumentLocator) {
823-
// that.m_hndDoc.setDocumentLocator(that);
824-
//}
825-
826-
that.m_bErr = false;
820+
//if(that.m_hndDoc && that.m_hndDoc.setDocumentLocator) {
821+
// that.m_hndDoc.setDocumentLocator(that);
822+
//}
827823

828-
if(!that.m_bErr && !startnew) {
829-
that._fireEvent(SaxParser.DOC_B);
830-
}
831-
that._parseLoop();
832-
if(!that.m_bErr && !that.m_interrupted) {
833-
that._fireEvent(SaxParser.DOC_E);
834-
}
824+
that.m_bErr = false;
835825

836-
that.m_xml = null;
837-
that.m_iP = 0;
838-
that.m_interrupted = false;
839-
}, 0);
826+
if(!that.m_bErr && !startnew) {
827+
that._fireEvent(SaxParser.DOC_B);
828+
}
829+
that._parseLoop();
830+
if(!that.m_bErr && !that.m_interrupted) {
831+
that._fireEvent(SaxParser.DOC_E);
832+
}
840833

834+
that.m_xml = null;
835+
that.m_iP = 0;
836+
that.m_interrupted = false;
841837
}
842838

843839
SaxParser.prototype.pause = function() {

0 commit comments

Comments
 (0)