summaryrefslogtreecommitdiff
path: root/Build/source/texk/dvisvgm/dvisvgm-src/src/FontEncoding.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/dvisvgm/dvisvgm-src/src/FontEncoding.cpp')
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-src/src/FontEncoding.cpp29
1 files changed, 10 insertions, 19 deletions
diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/FontEncoding.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/FontEncoding.cpp
index 886ab0ec6c6..d6f3325d31e 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-src/src/FontEncoding.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/FontEncoding.cpp
@@ -2,7 +2,7 @@
** FontEncoding.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2017 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2018 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -18,45 +18,36 @@
** along with this program; if not, see <http://www.gnu.org/licenses/>. **
*************************************************************************/
-#include <config.h>
#include "CMap.hpp"
#include "CMapManager.hpp"
#include "EncFile.hpp"
#include "FileFinder.hpp"
#include "FontEncoding.hpp"
+#include "utility.hpp"
using namespace std;
-
-struct EncodingMap : public map<string, EncFile*>
-{
- ~EncodingMap () {
- for (auto &entry : *this)
- delete entry.second;
- }
-};
-
-
/** Returns the encoding object for a given encoding name.
* @param[in] encname name of the encoding to lookup
* @return pointer to encoding object, or 0 if there is no encoding defined */
FontEncoding* FontEncoding::encoding (const string &encname) {
if (encname.empty())
return 0;
- // initially, try to find an .enc file with the given name
+
+ using EncodingMap = unordered_map<string, unique_ptr<EncFile>>;
static EncodingMap encmap;
- EncodingMap::const_iterator it = encmap.find(encname);
+ // initially, try to find an .enc file with the given name
+ auto it = encmap.find(encname);
if (it != encmap.end())
- return it->second;
+ return it->second.get();
if (FileFinder::instance().lookup(encname + ".enc", false)) {
- EncFile *enc = new EncFile(encname);
- encmap[encname] = enc;
- return enc;
+ auto state = encmap.emplace(encname, util::make_unique<EncFile>(encname));
+ return state.first->second.get();
}
// no .enc file found => try to find a CMap
if (CMap *cmap = CMapManager::instance().lookup(encname))
return cmap;
- return 0;
+ return nullptr;
}
/////////////////////////////////////////////////////////////////////////