summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-12-18 00:47:37 +0300
committerAndrei Karas <akaras@inbox.ru>2013-12-18 00:47:37 +0300
commit13358aab4dfcf636a2ef0905dd16e7045848d15c (patch)
treea9b03946a30b804f244a5147be3341df38318f02 /src/resources
parentd949db27719aeb5724e03536f7e86721bb78d78e (diff)
downloadplus-13358aab4dfcf636a2ef0905dd16e7045848d15c.tar.gz
plus-13358aab4dfcf636a2ef0905dd16e7045848d15c.tar.bz2
plus-13358aab4dfcf636a2ef0905dd16e7045848d15c.tar.xz
plus-13358aab4dfcf636a2ef0905dd16e7045848d15c.zip
add restrict into mapreader.
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/mapreader.cpp36
-rw-r--r--src/resources/mapreader.h15
2 files changed, 31 insertions, 20 deletions
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 1e94b06f2..ceedd3369 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -42,11 +42,14 @@
#include "debug.h"
-static int inflateMemory(unsigned char *const in, const unsigned int inLength,
- unsigned char *&out, unsigned int &outLength);
+static int inflateMemory(unsigned char *restrict const in,
+ const unsigned int inLength,
+ unsigned char *&restrict out,
+ unsigned int &restrict outLength);
-static int inflateMemory(unsigned char *const in, const unsigned int inLength,
- unsigned char *&out);
+static int inflateMemory(unsigned char *restrict const in,
+ const unsigned int inLength,
+ unsigned char *&restrict out);
static std::string resolveRelativePath(std::string base, std::string relative)
{
@@ -78,8 +81,10 @@ static std::string resolveRelativePath(std::string base, std::string relative)
* Inflates either zlib or gzip deflated memory. The inflated memory is
* expected to be freed by the caller.
*/
-int inflateMemory(unsigned char *const in, const unsigned int inLength,
- unsigned char *&out, unsigned int &outLength)
+int inflateMemory(unsigned char *restrict const in,
+ const unsigned int inLength,
+ unsigned char *&restrict out,
+ unsigned int &restrict outLength)
{
int bufferSize = 256 * 1024;
out = static_cast<unsigned char*>(calloc(bufferSize, 1));
@@ -143,8 +148,9 @@ int inflateMemory(unsigned char *const in, const unsigned int inLength,
return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
}
-int inflateMemory(unsigned char *const in, const unsigned int inLength,
- unsigned char *&out)
+int inflateMemory(unsigned char *restrict const in,
+ const unsigned int inLength,
+ unsigned char *&restrict out)
{
unsigned int outLength = 0;
const int ret = inflateMemory(in, inLength, out, outLength);
@@ -176,8 +182,8 @@ int inflateMemory(unsigned char *const in, const unsigned int inLength,
return outLength;
}
-Map *MapReader::readMap(const std::string &filename,
- const std::string &realFilename)
+Map *MapReader::readMap(const std::string &restrict filename,
+ const std::string &restrict realFilename)
{
BLOCK_START("MapReader::readMap")
logger->log("Attempting to read map %s", realFilename.c_str());
@@ -510,7 +516,8 @@ bool MapReader::readBase64Layer(const XmlNodePtr childNode, Map *const map,
const MapLayer::Type &layerType,
MapHeights *const heights,
const std::string &compression,
- int &x, int &y, const int w, const int h)
+ int &restrict x, int &restrict y,
+ const int w, const int h)
{
if (!compression.empty() && compression != "gzip"
&& compression != "zlib")
@@ -610,7 +617,8 @@ bool MapReader::readCsvLayer(const XmlNodePtr childNode, Map *const map,
MapLayer *const layer,
const MapLayer::Type &layerType,
MapHeights *const heights,
- int &x, int &y, const int w, const int h)
+ int &restrict x, int &restrict y,
+ const int w, const int h)
{
XmlNodePtr dataChild = childNode->xmlChildrenNode;
if (!dataChild)
@@ -944,8 +952,8 @@ Tileset *MapReader::readTileset(XmlNodePtr node, const std::string &path,
return set;
}
-Map *MapReader::createEmptyMap(const std::string &filename,
- const std::string &realFilename)
+Map *MapReader::createEmptyMap(const std::string &restrict filename,
+ const std::string &restrict realFilename)
{
logger->log1("Creating empty map");
Map *const map = new Map(300, 300, mapTileSize, mapTileSize);
diff --git a/src/resources/mapreader.h b/src/resources/mapreader.h
index 343dd9958..e6a5597e1 100644
--- a/src/resources/mapreader.h
+++ b/src/resources/mapreader.h
@@ -44,8 +44,9 @@ class MapReader final
/**
* Read an XML map from a file.
*/
- static Map *readMap(const std::string &filename,
- const std::string &realFilename) A_WARN_UNUSED;
+ static Map *readMap(const std::string &restrict filename,
+ const std::string &restrict realFilename)
+ A_WARN_UNUSED;
/**
* Read an XML map from a parsed XML tree. The path is used to find the
@@ -54,8 +55,8 @@ class MapReader final
static Map *readMap(XmlNodePtr node,
const std::string &path) A_WARN_UNUSED;
- static Map *createEmptyMap(const std::string &filename,
- const std::string &realFilename)
+ static Map *createEmptyMap(const std::string &restrict filename,
+ const std::string &restrict realFilename)
A_WARN_UNUSED;
private:
@@ -79,13 +80,15 @@ class MapReader final
const MapLayer::Type &layerType,
MapHeights *const heights,
const std::string &compression,
- int &x, int &y, const int w, const int h);
+ int &restrict x, int &restrict y,
+ const int w, const int h);
static bool readCsvLayer(const XmlNodePtr childNode, Map *const map,
MapLayer *const layer,
const MapLayer::Type &layerType,
MapHeights *const heights,
- int &x, int &y, const int w, const int h);
+ int &restrict x, int &restrict y,
+ const int w, const int h);
/**
* Reads a tile set.