aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerländer2014-04-26 15:17:07 +0200
committerAdrian Kummerländer2014-04-26 15:17:07 +0200
commit7e7b112e6c00bcce0b339652748079cf7c9f1430 (patch)
tree645cab42adbfa79f0a32ed85f00805f73263d9f6
parent0b611b7bd28851fe8096b3d2c121c68e231ada11 (diff)
downloadInputXSLT-7e7b112e6c00bcce0b339652748079cf7c9f1430.tar
InputXSLT-7e7b112e6c00bcce0b339652748079cf7c9f1430.tar.gz
InputXSLT-7e7b112e6c00bcce0b339652748079cf7c9f1430.tar.bz2
InputXSLT-7e7b112e6c00bcce0b339652748079cf7c9f1430.tar.lz
InputXSLT-7e7b112e6c00bcce0b339652748079cf7c9f1430.tar.xz
InputXSLT-7e7b112e6c00bcce0b339652748079cf7c9f1430.tar.zst
InputXSLT-7e7b112e6c00bcce0b339652748079cf7c9f1430.zip
Moved DomDocumentCache instances back into external function class
* A global DomDocumentCache instance would require key prefixing * switched internal data structure to std::unordered_map for average constant time access
-rw-r--r--src/function/read_directory.cc7
-rw-r--r--src/function/read_directory.h6
-rw-r--r--src/support/dom/document_cache.h4
-rw-r--r--src/transformation_facade.cc5
-rw-r--r--src/transformation_facade.h2
5 files changed, 11 insertions, 13 deletions
diff --git a/src/function/read_directory.cc b/src/function/read_directory.cc
index 677aa1d..3f503b3 100644
--- a/src/function/read_directory.cc
+++ b/src/function/read_directory.cc
@@ -11,10 +11,9 @@
namespace InputXSLT {
-FunctionReadDirectory::FunctionReadDirectory(const FilesystemContext& context,
- DomDocumentCache& cache):
+FunctionReadDirectory::FunctionReadDirectory(const FilesystemContext& context):
fs_context_(context),
- document_cache_(cache) { }
+ document_cache_(std::make_shared<DomDocumentCache>()) { }
xalan::XObjectPtr FunctionReadDirectory::execute(
xalan::XPathExecutionContext& executionContext,
@@ -23,7 +22,7 @@ xalan::XObjectPtr FunctionReadDirectory::execute(
const xalan::Locator*
) const {
DomDocumentCache::item* const cachedDocument(
- this->document_cache_.get(xalanToString(argument->str()))
+ this->document_cache_->get(xalanToString(argument->str()))
);
if ( !cachedDocument->isFinalized() ) {
diff --git a/src/function/read_directory.h b/src/function/read_directory.h
index 3fcf389..f4f7ec8 100644
--- a/src/function/read_directory.h
+++ b/src/function/read_directory.h
@@ -6,6 +6,8 @@
#include <xalanc/XPath/Function.hpp>
#include <xalanc/XPath/XObject.hpp>
+#include <memory>
+
#include "common.h"
#include "support/filesystem_context.h"
#include "support/dom/document_cache.h"
@@ -14,7 +16,7 @@ namespace InputXSLT {
class FunctionReadDirectory : public xalan::Function {
public:
- FunctionReadDirectory(const FilesystemContext&, DomDocumentCache&);
+ FunctionReadDirectory(const FilesystemContext&);
virtual xalan::XObjectPtr execute(
xalan::XPathExecutionContext&,
@@ -30,7 +32,7 @@ class FunctionReadDirectory : public xalan::Function {
private:
const FilesystemContext& fs_context_;
- DomDocumentCache& document_cache_;
+ std::shared_ptr<DomDocumentCache> document_cache_;
const xalan::XalanDOMString& getError(xalan::XalanDOMString&) const;
diff --git a/src/support/dom/document_cache.h b/src/support/dom/document_cache.h
index 4447a18..287a316 100644
--- a/src/support/dom/document_cache.h
+++ b/src/support/dom/document_cache.h
@@ -1,7 +1,7 @@
#ifndef INPUTXSLT_SRC_SUPPORT_DOM_DOCUMENT_CACHE_H_
#define INPUTXSLT_SRC_SUPPORT_DOM_DOCUMENT_CACHE_H_
-#include <map>
+#include <unordered_map>
#include <string>
#include <memory>
@@ -16,7 +16,7 @@ class DomDocumentCache {
item* get(const std::string&);
private:
- std::map<std::string, std::unique_ptr<item>> map_;
+ std::unordered_map<std::string, std::unique_ptr<item>> map_;
};
diff --git a/src/transformation_facade.cc b/src/transformation_facade.cc
index cb89263..38dfe93 100644
--- a/src/transformation_facade.cc
+++ b/src/transformation_facade.cc
@@ -15,8 +15,7 @@ namespace InputXSLT {
TransformationFacade::TransformationFacade(const std::string& transformation):
fs_context_(boost::filesystem::path(transformation).parent_path().string()),
transformation_{},
- transformer_(),
- document_cache_() {
+ transformer_() {
const xalan::XalanDOMString customNamespace(
"http://ExternalFunction.xalan-c++.xml.apache.org"
);
@@ -36,7 +35,7 @@ TransformationFacade::TransformationFacade(const std::string& transformation):
this->transformer_.installExternalFunction(
customNamespace,
xalan::XalanDOMString("read-directory"),
- InputXSLT::FunctionReadDirectory(this->fs_context_, this->document_cache_)
+ InputXSLT::FunctionReadDirectory(this->fs_context_)
);
this->transformer_.compileStylesheet(
diff --git a/src/transformation_facade.h b/src/transformation_facade.h
index 3acb364..765a376 100644
--- a/src/transformation_facade.h
+++ b/src/transformation_facade.h
@@ -7,7 +7,6 @@
#include "common.h"
#include "support/filesystem_context.h"
-#include "support/dom/document_cache.h"
namespace InputXSLT {
@@ -23,7 +22,6 @@ class TransformationFacade {
const xalan::XalanCompiledStylesheet* transformation_;
xalan::XalanTransformer transformer_;
- DomDocumentCache document_cache_;
};