From 2efc6fb6d3c83de93a8204dfa828e7410ec7d283 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sat, 11 Jan 2020 23:41:04 +0100 Subject: [PATCH] Optimization --- src/map/IMG/lblfile.cpp | 5 ++--- src/map/IMG/lblfile.h | 2 +- src/map/IMG/netfile.cpp | 5 ++--- src/map/IMG/netfile.h | 2 +- src/map/IMG/rgnfile.cpp | 7 +++---- src/map/IMG/rgnfile.h | 2 +- 6 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/map/IMG/lblfile.cpp b/src/map/IMG/lblfile.cpp index a1b6f9d9..ca45b545 100644 --- a/src/map/IMG/lblfile.cpp +++ b/src/map/IMG/lblfile.cpp @@ -50,9 +50,8 @@ static QString capitalize(const QString &str) } -bool LBLFile::init() +bool LBLFile::init(Handle &hdl) { - Handle hdl; quint16 codepage; quint8 multiplier, poiMultiplier; @@ -165,7 +164,7 @@ Label LBLFile::label8b(Handle &hdl, quint32 offset) const Label LBLFile::label(Handle &hdl, quint32 offset, bool poi) { - if (!_multiplier && !init()) + if (!_multiplier && !init(hdl)) return QString(); quint32 labelOffset; diff --git a/src/map/IMG/lblfile.h b/src/map/IMG/lblfile.h index b7a44670..493f4024 100644 --- a/src/map/IMG/lblfile.h +++ b/src/map/IMG/lblfile.h @@ -19,7 +19,7 @@ public: Label label(Handle &hdl, quint32 offset, bool poi = false); private: - bool init(); + bool init(Handle &hdl); Label label6b(Handle &hdl, quint32 offset) const; Label label8b(Handle &hdl, quint32 offset) const; diff --git a/src/map/IMG/netfile.cpp b/src/map/IMG/netfile.cpp index 36c632b3..f8514c4f 100644 --- a/src/map/IMG/netfile.cpp +++ b/src/map/IMG/netfile.cpp @@ -1,8 +1,7 @@ #include "netfile.h" -bool NETFile::init() +bool NETFile::init(Handle &hdl) { - Handle hdl; quint8 multiplier; if (!(seek(hdl, _gmpOffset + 0x15) && readUInt32(hdl, _offset) @@ -16,7 +15,7 @@ bool NETFile::init() bool NETFile::lblOffset(Handle &hdl, quint32 netOffset, quint32 &lblOffset) { - if (!_multiplier && !init()) + if (!_multiplier && !init(hdl)) return false; if (!(seek(hdl, _offset + netOffset * _multiplier) diff --git a/src/map/IMG/netfile.h b/src/map/IMG/netfile.h index a7bf8183..5db8c6bb 100644 --- a/src/map/IMG/netfile.h +++ b/src/map/IMG/netfile.h @@ -13,7 +13,7 @@ public: bool lblOffset(Handle &hdl, quint32 netOffset, quint32 &lblOffset); private: - bool init(); + bool init(Handle &hdl); quint32 _offset; quint32 _size; diff --git a/src/map/IMG/rgnfile.cpp b/src/map/IMG/rgnfile.cpp index 5df81a27..2a4f3dd9 100644 --- a/src/map/IMG/rgnfile.cpp +++ b/src/map/IMG/rgnfile.cpp @@ -119,9 +119,8 @@ bool RGNFile::DeltaStream::sign(int &val) } -bool RGNFile::init() +bool RGNFile::init(Handle &hdl) { - Handle hdl; quint16 hdrLen; if (!(seek(hdl, _gmpOffset) && readUInt16(hdl, hdrLen) @@ -395,7 +394,7 @@ void RGNFile::objects(const RectC &rect, const SubDiv *subdiv, LBLFile *lbl, { Handle rgnHdl, lblHdl, netHdl; - if (!_init && !init()) + if (!_init && !init(rgnHdl)) return; QVector seg(segments(rgnHdl, subdiv)); @@ -427,7 +426,7 @@ void RGNFile::extObjects(const RectC &rect, const SubDiv *subdiv, LBLFile *lbl, { Handle rgnHdl, lblHdl; - if (!_init && !init()) + if (!_init && !init(rgnHdl)) return; if (polygons && subdiv->polygonsOffset() != subdiv->polygonsEnd()) { diff --git a/src/map/IMG/rgnfile.h b/src/map/IMG/rgnfile.h index 3ab4a81a..b1d6f45c 100644 --- a/src/map/IMG/rgnfile.h +++ b/src/map/IMG/rgnfile.h @@ -93,7 +93,7 @@ private: quint32 _lonBits, _latBits, _readBits; }; - bool init(); + bool init(Handle &hdl); QVector segments(Handle &hdl, const SubDiv *subdiv) const; bool polyObjects(const RectC &rect, Handle &hdl, const SubDiv *subdiv,