Hi,
I was looking trough the svn code today. And I noticed some variables that
could be made const. This is always nice since the compiler can then do some
more optimalisation. I have tested them myself and did not notice anny odd
behavoir. I'll check some more code when I get back home this afternoon.
Roeland
--- Utils/SlippyMapWidget.h (revision 8339)
+++ Utils/SlippyMapWidget.h (working copy)
@@ -33,10 +33,10 @@
void setMap(SlippyMapWidgetPrivate* aMap);
- QPixmap* getImage(int x, int y, int Zoom);
- QPixmap* getDirty(int x, int y, int Zoom);
+ QPixmap* getImage(const int x, const int y, const int Zoom);
+ QPixmap* getDirty(const int x, const int y, const int Zoom);
private slots:
- void on_requestFinished(int id, bool Error);
+ void on_requestFinished(const int id, const bool Error);
private:
void addToQueue(const Coord& C);
void startDownload();
--- Map/ImportGPX.cpp (revision 8339)
+++ Map/ImportGPX.cpp (working copy)
@@ -15,8 +15,8 @@
static TrackPoint* importTrkPt(const QDomElement& Root, MapDocument* /* theDocument */, MapLayer* theLayer, CommandList* theList)
{
- double Lat = Root.attribute("lat").toDouble();
- double Lon = Root.attribute("lon").toDouble();
+ const double Lat = Root.attribute("lat").toDouble();
+ const double Lon = Root.attribute("lon").toDouble();
TrackPoint* Pt = new TrackPoint(Coord(angToRad(Lat),angToRad(Lon)));
theList->add(new AddFeatureCommand(theLayer,Pt, true));
--- Map/Coord.h (revision 8339)
+++ Map/Coord.h (working copy)
@@ -6,12 +6,12 @@
#include <QtDebug>
#include <QtXml>
-inline double angToRad(double a)
+static inline double angToRad(const double a)
{
return a*M_PI/180;
}
-inline double radToAng(double a)
+static inline double radToAng(const double a)
{
return a*180/M_PI;
}
--- Map/DownloadOSM.cpp (revision 8339)
+++ Map/DownloadOSM.cpp (working copy)
@@ -38,7 +38,7 @@
UseProxy(aUseProxy), ProxyHost(aProxyHost), ProxyPort(aProxyPort), Id(0),
Error(false), Animator(0), AnimatorBar(0), AnimationTimer(0)
{
- int p = Web.lastIndexOf(':');
+ const int p = Web.lastIndexOf(':');
if (p != -1)
{
Port = Web.right(Web.length()-(p+1)).toUInt();
@@ -111,7 +111,6 @@
{
QByteArray Total;
- int ret;
unsigned have;
z_stream strm;
char in[CHUNK+2];
@@ -122,12 +121,12 @@
strm.opaque = Z_NULL;
strm.avail_in = 0;
strm.next_in = Z_NULL;
- ret = inflateInit2(&strm,15+32);
- if (ret != Z_OK)
- {
- (void)inflateEnd(&strm);
+ int ret = inflateInit2(&strm,15+32);
+ if (ret != Z_OK)
+ {
+ (void)inflateEnd(&strm);
return Total;
- }
+ }
unsigned int RealSize = In.size();
for (unsigned int i=0; i<RealSize/CHUNK+1; ++i)
{
@@ -145,10 +144,10 @@
strm.next_out = reinterpret_cast<unsigned char*>(out);
ret = inflate(&strm, Z_NO_FLUSH);
if (ret == Z_STREAM_ERROR)
- {
- (void)inflateEnd(&strm);
+ {
+ (void)inflateEnd(&strm);
return Total;
- }
+ }
switch (ret)
{
case Z_NEED_DICT:
@@ -163,13 +162,10 @@
Total.append(QByteArray(out,have));
} while (strm.avail_out == 0);
}
- (void)inflateEnd(&strm);
+ (void)inflateEnd(&strm);
return Total;
}
-
-
-
bool Downloader::go(const QString& url)
{
if (Error) return false;
_______________________________________________
Merkaartor mailing list
[email protected]
http://lists.openstreetmap.org/cgi-bin/mailman/listinfo/merkaartor