i know its crazy, but attempt performance gains by avoiding use of int64 as much as possible.

This commit is contained in:
Mark Vejvoda
2013-11-03 07:18:27 +00:00
parent f461504541
commit 8d4f5a9f40
4 changed files with 34 additions and 12 deletions

View File

@@ -19,6 +19,7 @@
#include <iostream>
#include <locale>
#include "platform_util.h"
#include <limits>
#include "leak_dumper.h"
using namespace std;
@@ -132,15 +133,27 @@ string boolToStr(bool b) {
}
}
string intToStr(int64 i) {
string intToStr(const int64 &value) {
char str[strSize]="";
snprintf(str, strSize-1, "%lld", (long long int)i);
static int MAX_INT_VALUE = std::numeric_limits<int>::max();
if(value <= MAX_INT_VALUE) {
snprintf(str, strSize-1, "%d", (int)value);
}
else {
snprintf(str, strSize-1, "%lld", (long long int)value);
}
return (str[0] != '\0' ? str : "");
}
string uIntToStr(uint32 i) {
string uIntToStr(const uint64 &value) {
char str[strSize]="";
snprintf(str, strSize-1, "%u", i);
static unsigned int MAX_UNSIGNED_INT_VALUE = std::numeric_limits<unsigned int>::max();
if(value <= MAX_UNSIGNED_INT_VALUE) {
snprintf(str, strSize-1, "%u", (int)value);
}
else {
snprintf(str, strSize-1, "%llu", (long long unsigned int)value);
}
return (str[0] != '\0' ? str : "");
}

View File

@@ -502,7 +502,7 @@ XmlTree::XmlTree(xml_engine_parser_type engine_type) {
break;
default:
throw megaglest_runtime_error("Invalid XML parser engine: " + intToStr(engine_type));
throw megaglest_runtime_error("Invalid XML parser engine: " + intToStr((int)engine_type));
}
this->engine_type = engine_type;
@@ -689,7 +689,7 @@ XmlNode::~XmlNode() {
XmlAttribute *XmlNode::getAttribute(unsigned int i) const {
if(i >= attributes.size()) {
throw megaglest_runtime_error(getName()+" node doesn't have "+intToStr(i)+" attributes");
throw megaglest_runtime_error(getName()+" node doesn't have " + uIntToStr(i) + " attributes");
}
return attributes[i];
}
@@ -733,7 +733,7 @@ int XmlNode::clearChild(const string &childName) {
XmlNode *XmlNode::getChild(unsigned int i) const {
assert(!superNode);
if(i >= children.size()) {
throw megaglest_runtime_error("\"" + getName()+"\" node doesn't have "+intToStr(i+1)+" children");
throw megaglest_runtime_error("\"" + getName()+"\" node doesn't have "+ uIntToStr(i+1) + " children");
}
return children[i];
}
@@ -754,7 +754,7 @@ XmlNode *XmlNode::getChild(const string &childName, unsigned int i) const {
return superNode->getChild(childName,i);
}
if(i >= children.size()) {
throw megaglest_runtime_error("\"" + name + "\" node doesn't have "+intToStr(i+1)+" children named \"" + childName + "\"\n\nTree: "+getTreeString());
throw megaglest_runtime_error("\"" + name + "\" node doesn't have " + uIntToStr(i+1) +" children named \"" + childName + "\"\n\nTree: "+getTreeString());
}
int count= 0;
@@ -767,7 +767,7 @@ XmlNode *XmlNode::getChild(const string &childName, unsigned int i) const {
}
}
throw megaglest_runtime_error("Node \""+getName()+"\" doesn't have "+intToStr(i+1)+" children named \""+childName+"\"\n\nTree: "+getTreeString());
throw megaglest_runtime_error("Node \""+getName()+"\" doesn't have " + uIntToStr(i+1) + " children named \""+childName+"\"\n\nTree: "+getTreeString());
}
bool XmlNode::hasChildNoSuper(const string &childName) const {