1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 03:35:53 +01:00

Only use the wildcard compare where it should be used

+ QT6 build fix
This commit is contained in:
Martin Tůma 2021-04-10 15:49:48 +02:00
parent 44a5e5de81
commit f2585486b6
6 changed files with 17 additions and 31 deletions

View File

@ -104,7 +104,6 @@ HEADERS += src/common/config.h \
src/map/IMG/raster.h \
src/map/IMG/rastertile.h \
src/map/IMG/shield.h \
src/map/mapsforge/cmp.h \
src/map/mapsforge/style.h \
src/map/textpathitem.h \
src/map/textpointitem.h \

View File

@ -1,22 +0,0 @@
#ifndef MAPSFORGE_CMP_H
#define MAPSFORGE_CMP_H
#include <QByteArray>
#include <cstring>
namespace Mapsforge {
inline bool cmp(const QByteArray &b1, const QByteArray &b2)
{
int len = b1.length();
if (!len)
return true;
if (len != b2.length())
return false;
return !memcmp(b1.constData(), b2.constData(), len);
}
}
#endif // MAPSFORGE_CMP_H

View File

@ -9,7 +9,6 @@
#include "common/rtree.h"
#include "common/range.h"
#include "common/polygon.h"
#include "cmp.h"
namespace Mapsforge {
@ -34,7 +33,7 @@ public:
}
bool operator==(const Tag &other) const
{return cmp(key, other.key) && cmp(value, other.value);}
{return (key == other.key && value == other.value);}
QByteArray key;
QByteArray value;

View File

@ -6,7 +6,6 @@
#include "map/transform.h"
#include "style.h"
#include "mapdata.h"
#include "cmp.h"
class MapsforgeMap;
class TextItem;

View File

@ -205,9 +205,9 @@ void Style::rule(QXmlStreamReader &reader, const QString &dir,
return;
}
if (attr.value("e") == "way")
if (attr.value("e").toString() == "way")
r.setType(Rule::WayType);
else if (attr.value("e") == "node")
else if (attr.value("e").toString() == "node")
r.setType(Rule::NodeType);
if (attr.hasAttribute("zoom-min"))
@ -224,7 +224,7 @@ void Style::rule(QXmlStreamReader &reader, const QString &dir,
QList<QByteArray> keys(attr.value("k").toLatin1().split('|'));
QList<QByteArray> vals(attr.value("v").toLatin1().split('|'));
r.addFilter(Rule::Filter(keys, vals));
r.addFilter(Rule::Filter(keys, vals));
while (reader.readNextStartElement()) {
if (reader.name() == QLatin1String("rule"))

View File

@ -11,6 +11,17 @@ class QXmlStreamReader;
namespace Mapsforge {
inline bool wcmp(const QByteArray &b1, const QByteArray &b2)
{
int len = b1.length();
if (!len)
return true;
if (len != b2.length())
return false;
return !memcmp(b1.constData(), b2.constData(), len);
}
class Style
{
public:
@ -85,7 +96,7 @@ public:
{
for (int i = 0; i < _keys.size(); i++)
for (int j = 0; j < tags.size(); j++)
if (cmp(_keys.at(i), tags.at(j).key))
if (wcmp(_keys.at(i), tags.at(j).key))
return true;
return false;
@ -95,7 +106,7 @@ public:
{
for (int i = 0; i < _vals.size(); i++)
for (int j = 0; j < tags.size(); j++)
if (cmp(_vals.at(i), tags.at(j).value))
if (wcmp(_vals.at(i), tags.at(j).value))
return true;
return false;