From a53fedf83844fb77082fa5be970bd5f6cc292479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Wed, 21 Jul 2021 02:06:35 +0200 Subject: [PATCH] Yet another unnecessary file open remove --- src/map/IMG/netfile.cpp | 8 ++++---- src/map/IMG/netfile.h | 7 ++++--- src/map/IMG/nodfile.h | 6 +++--- src/map/IMG/rgnfile.cpp | 5 +++-- src/map/IMG/rgnfile.h | 3 ++- src/map/IMG/vectortile.cpp | 14 ++++++++++---- 6 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/map/IMG/netfile.cpp b/src/map/IMG/netfile.cpp index 58c58922..46caa027 100644 --- a/src/map/IMG/netfile.cpp +++ b/src/map/IMG/netfile.cpp @@ -411,9 +411,9 @@ void NETFile::clear() } bool NETFile::link(const SubDiv *subdiv, quint32 shift, Handle &hdl, - const NODFile *nod, Handle &nodHdl, const LBLFile *lbl, Handle &lblHdl, - const NODFile::BlockInfo &blockInfo, quint8 linkId, quint8 lineId, - QList *lines) const + const NODFile *nod, Handle &nodHdl2, Handle &nodHdl, const LBLFile *lbl, + Handle &lblHdl, const NODFile::BlockInfo &blockInfo, quint8 linkId, + quint8 lineId, QList *lines) const { MapData::Poly poly; if (!nod->linkType(nodHdl, blockInfo, linkId, poly.type)) @@ -447,7 +447,7 @@ bool NETFile::link(const SubDiv *subdiv, quint32 shift, Handle &hdl, } if (!subdiv->level()) { - NODFile::AdjacencyInfo adj(nod, blockInfo, linkId, linkInfo); + NODFile::AdjacencyInfo adj(nodHdl2, blockInfo, linkId, linkInfo); if (singleTopology) { if (firstIsShape) { diff --git a/src/map/IMG/netfile.h b/src/map/IMG/netfile.h index d277213d..51d79d3c 100644 --- a/src/map/IMG/netfile.h +++ b/src/map/IMG/netfile.h @@ -30,9 +30,10 @@ public: bool lblOffset(Handle &hdl, quint32 netOffset, quint32 &lblOffset) const; bool link(const SubDiv *subdiv, quint32 shift, Handle &hdl, - const NODFile *nod, Handle &nodHdl, const LBLFile *lbl, Handle &lblHdl, - const NODFile::BlockInfo &blockInfo, quint8 linkId, quint8 lineId, - QList *lines) const; + const NODFile *nod, Handle &nodHdl2, Handle &nodHdl, const LBLFile *lbl, + Handle &lblHdl, const NODFile::BlockInfo &blockInfo, quint8 linkId, + quint8 lineId, QList *lines) const; + bool hasLinks() const {return (_linksSize > 0);} private: bool linkLabel(Handle &hdl, quint32 offset, quint32 size, diff --git a/src/map/IMG/nodfile.h b/src/map/IMG/nodfile.h index b29b06d0..e3e331bd 100644 --- a/src/map/IMG/nodfile.h +++ b/src/map/IMG/nodfile.h @@ -40,13 +40,13 @@ public: struct AdjacencyInfo { - AdjacencyInfo(const SubFile *file, const BlockInfo &blockInfo, - quint32 linkId, const LinkInfo &linkInfo) : extHdl(file), + AdjacencyInfo(Handle &hdl, const BlockInfo &blockInfo, + quint32 linkId, const LinkInfo &linkInfo) : extHdl(hdl), blockInfo(blockInfo), nodeOffset(linkInfo.nodeOffset), linkOffset(linkInfo.linkOffset), linkId(linkId) {} - Handle extHdl; + Handle &extHdl; BlockInfo blockInfo; NodeInfo nodeInfo; quint32 nodeOffset; diff --git a/src/map/IMG/rgnfile.cpp b/src/map/IMG/rgnfile.cpp index e03e78d0..b975105d 100644 --- a/src/map/IMG/rgnfile.cpp +++ b/src/map/IMG/rgnfile.cpp @@ -456,7 +456,8 @@ bool RGNFile::extPointObjects(Handle &hdl, const SubDiv *subdiv, bool RGNFile::links(Handle &hdl, const SubDiv *subdiv, quint32 shift, const NETFile *net, Handle &netHdl, const NODFile *nod, Handle &nodHdl, - const LBLFile *lbl, Handle &lblHdl, QList *lines) const + Handle &nodHdl2, const LBLFile *lbl, Handle &lblHdl, + QList *lines) const { quint32 size, blockIndexId; quint8 flags; @@ -522,7 +523,7 @@ bool RGNFile::links(Handle &hdl, const SubDiv *subdiv, quint32 shift, lineId = 0; } - net->link(subdiv, shift, netHdl, nod, nodHdl, lbl, lblHdl, + net->link(subdiv, shift, netHdl, nod, nodHdl, nodHdl2, lbl, lblHdl, blockInfo, linkId, lineId, lines); } diff --git a/src/map/IMG/rgnfile.h b/src/map/IMG/rgnfile.h index 97388ea2..8a6e8d9c 100644 --- a/src/map/IMG/rgnfile.h +++ b/src/map/IMG/rgnfile.h @@ -51,7 +51,8 @@ public: Handle &lblHdl, QList *points) const; bool links(Handle &hdl, const SubDiv *subdiv, quint32 shift, const NETFile *net, Handle &netHdl, const NODFile *nod, Handle &nodHdl, - const LBLFile *lbl, Handle &lblHdl, QList *lines) const; + Handle &nodHdl2, const LBLFile *lbl, Handle &lblHdl, + QList *lines) const; bool subdivInit(Handle &hdl, SubDiv *subdiv) const; diff --git a/src/map/IMG/vectortile.cpp b/src/map/IMG/vectortile.cpp index 255be4da..bda064ae 100644 --- a/src/map/IMG/vectortile.cpp +++ b/src/map/IMG/vectortile.cpp @@ -104,7 +104,8 @@ void VectorTile::polys(const RectC &rect, int bits, bool baseMap, QList *polygons, QList *lines, QCache *polyCache) { - SubFile::Handle *rgnHdl = 0, *lblHdl = 0, *netHdl = 0, *nodHdl = 0; + SubFile::Handle *rgnHdl = 0, *lblHdl = 0, *netHdl = 0, *nodHdl = 0, + *nodHdl2 = 0; if (_loaded < 0) return; @@ -147,8 +148,13 @@ void VectorTile::polys(const RectC &rect, int bits, bool baseMap, *lblHdl, &p); _rgn->extPolyObjects(*rgnHdl, subdiv, shift, RGNFile::Line, _lbl, *lblHdl, &l); - _rgn->links(*rgnHdl, subdiv, shift, _net, *netHdl, _nod, *nodHdl, - _lbl, *lblHdl, &l); + + if (_net && _net->hasLinks()) { + if (!nodHdl2) + nodHdl2 = new SubFile::Handle(_nod); + _rgn->links(*rgnHdl, subdiv, shift, _net, *netHdl, _nod, *nodHdl, + *nodHdl2, _lbl, *lblHdl, &l); + } copyPolys(rect, &p, polygons); copyPolys(rect, &l, lines); @@ -159,7 +165,7 @@ void VectorTile::polys(const RectC &rect, int bits, bool baseMap, } } - delete rgnHdl; delete lblHdl; delete netHdl; delete nodHdl; + delete rgnHdl; delete lblHdl; delete netHdl; delete nodHdl; delete nodHdl2; } void VectorTile::points(const RectC &rect, int bits, bool baseMap,