leave early to reduce scope nesting

This commit is contained in:
Dennis Luxen 2014-05-13 12:22:42 +02:00
parent 111dea89a9
commit 981941edf4

View File

@ -103,8 +103,8 @@ InputRestrictionContainer XMLParser::ReadXMLRestriction()
const int depth = xmlTextReaderDepth(inputReader);
while (xmlTextReaderRead(inputReader) == 1)
{
const int childType = xmlTextReaderNodeType(inputReader);
if (childType != 1 && childType != 15)
const int child_type = xmlTextReaderNodeType(inputReader);
if (child_type != 1 && child_type != 15)
{
continue;
}
@ -114,13 +114,13 @@ InputRestrictionContainer XMLParser::ReadXMLRestriction()
{
continue;
}
if (depth == childDepth && childType == 15 &&
if (depth == childDepth && child_type == 15 &&
xmlStrEqual(childName, (const xmlChar *)"relation") == 1)
{
xmlFree(childName);
break;
}
if (childType != 1)
if (child_type != 1)
{
xmlFree(childName);
continue;
@ -204,13 +204,15 @@ InputRestrictionContainer XMLParser::ReadXMLRestriction()
ExtractionWay XMLParser::ReadXMLWay()
{
ExtractionWay way;
if (xmlTextReaderIsEmptyElement(inputReader) != 1)
if (xmlTextReaderIsEmptyElement(inputReader) == 1)
{
return way;
}
const int depth = xmlTextReaderDepth(inputReader);
while (xmlTextReaderRead(inputReader) == 1)
{
const int childType = xmlTextReaderNodeType(inputReader);
if (childType != 1 && childType != 15)
const int child_type = xmlTextReaderNodeType(inputReader);
if (child_type != 1 && child_type != 15)
{
continue;
}
@ -221,7 +223,7 @@ ExtractionWay XMLParser::ReadXMLWay()
continue;
}
if (depth == childDepth && childType == 15 &&
if (depth == childDepth && child_type == 15 &&
xmlStrEqual(childName, (const xmlChar *)"way") == 1)
{
xmlChar *id = xmlTextReaderGetAttribute(inputReader, (const xmlChar *)"id");
@ -230,7 +232,7 @@ ExtractionWay XMLParser::ReadXMLWay()
xmlFree(childName);
break;
}
if (childType != 1)
if (child_type != 1)
{
xmlFree(childName);
continue;
@ -265,7 +267,6 @@ ExtractionWay XMLParser::ReadXMLWay()
}
xmlFree(childName);
}
}
return way;
}
@ -292,14 +293,16 @@ ImportNode XMLParser::ReadXMLNode()
xmlFree(attribute);
}
if (xmlTextReaderIsEmptyElement(inputReader) != 1)
if (xmlTextReaderIsEmptyElement(inputReader) == 1)
{
return node;
}
const int depth = xmlTextReaderDepth(inputReader);
while (xmlTextReaderRead(inputReader) == 1)
{
const int childType = xmlTextReaderNodeType(inputReader);
const int child_type = xmlTextReaderNodeType(inputReader);
// 1 = Element, 15 = EndElement
if (childType != 1 && childType != 15)
if (child_type != 1 && child_type != 15)
{
continue;
}
@ -310,13 +313,13 @@ ImportNode XMLParser::ReadXMLNode()
continue;
}
if (depth == childDepth && childType == 15 &&
if (depth == childDepth && child_type == 15 &&
xmlStrEqual(childName, (const xmlChar *)"node") == 1)
{
xmlFree(childName);
break;
}
if (childType != 1)
if (child_type != 1)
{
xmlFree(childName);
continue;
@ -342,6 +345,5 @@ ImportNode XMLParser::ReadXMLNode()
xmlFree(childName);
}
}
return node;
}