Browse Source

perf improvement

master
alistair 3 years ago
parent
commit
26841f2aca
  1. 3
      CMakeLists.txt
  2. 5
      main.cpp
  3. 12
      templater.hpp

3
CMakeLists.txt

@ -78,7 +78,8 @@ target_link_libraries(stgen3 PRIVATE ${CMAKE_SOURCE_DIR}/itexToMML/itex-src/libi @@ -78,7 +78,8 @@ target_link_libraries(stgen3 PRIVATE ${CMAKE_SOURCE_DIR}/itexToMML/itex-src/libi
target_link_libraries(stgen3 PRIVATE ${CMAKE_SOURCE_DIR}/lib/mtex2MML/build/libmtex2MML.a)
target_link_libraries(stgen3 PRIVATE tinyxml2)
target_link_libraries(stgen3 PRIVATE lexbor )
target_link_libraries(stgen3 PRIVATE source-highlight)
target_link_libraries(stgen3 PRIVATE ${CMAKE_SOURCE_DIR}/lib/src-highlite/build/b/lib/libsource-highlight.a)
target_link_libraries(stgen3 PRIVATE boost_regex)
target_link_libraries(stgen3 PRIVATE
${CMAKE_SOURCE_DIR}/lib/lasem/src/.libs/liblasem-0.6.so ${GLIB_LIBRARIES} m
pthread /usr/lib64/libgobject-2.0.so.0 /usr/lib64/libcairo.so.2)

5
main.cpp

@ -215,7 +215,7 @@ class Imtex { @@ -215,7 +215,7 @@ class Imtex {
lsm_dom_document_save_to_memory (doc, &tbuffer, &size, NULL);
std::string mathml {tbuffer, tbuffer + size};
spdlog::info("Mathml: {}", mathml);
// spdlog::info("Mathml: {}", mathml);
g_free (tbuffer);
@ -1104,8 +1104,9 @@ class builder { @@ -1104,8 +1104,9 @@ class builder {
e.second.properties.erase("body");
std::optional<const std::unordered_map<fs::path, blog_item, pathHash>> non {compile_jobs};
s2_templr->run_substitution_plugins(page,
e.second.properties, compile_jobs);
e.second.properties, non);
e.second.properties["body"] = page;
}

12
templater.hpp

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
// ./stgen3 src dest 7.98s user 0.32s system 102% cpu 8.123 total
#include <map>
#include <ranges>
#include <stack>
@ -834,6 +835,7 @@ class templater { @@ -834,6 +835,7 @@ class templater {
std::unordered_map<std::string, substitution_plugin *> substitution_commands {};
std::unordered_map<std::string, s2_substitution_plugin *> s2_substitution_commands {};
const std::optional<const std::unordered_map<fs::path, blog_item, pathHash>> NO_PAGES {};
public:
@ -872,7 +874,7 @@ class templater { @@ -872,7 +874,7 @@ class templater {
do_substitution(int start, int end, const std::string &invocation,
std::string &file_text,
const std::unordered_map<std::string, std::string> &properties,
std::optional<const std::unordered_map<fs::path, blog_item, pathHash>> pages)
const std::optional<const std::unordered_map<fs::path, blog_item, pathHash>> &pages)
{
std::string command_name = invocation.substr(0, invocation.find(":"));
@ -903,19 +905,19 @@ class templater { @@ -903,19 +905,19 @@ class templater {
run_substitution_plugins(std::string &text,
const std::unordered_map<std::string, std::string> &properties)
{
run_substitution_plugins(text, properties, {}, true);
run_substitution_plugins(text, properties, NO_PAGES, true);
}
void
run_substitution_plugins_once(std::string &text,
const std::unordered_map<std::string, std::string> &properties)
{
run_substitution_plugins(text, properties, {}, false);
run_substitution_plugins(text, properties, NO_PAGES, false);
}
void
run_substitution_plugins(std::string &text,
const std::unordered_map<std::string, std::string> &properties, std::optional<const std::unordered_map<fs::path, blog_item, pathHash>> pages) {
const std::unordered_map<std::string, std::string> &properties, const std::optional<const std::unordered_map<fs::path, blog_item, pathHash>> &pages) {
run_substitution_plugins(text, properties,pages,true);
}
@ -923,7 +925,7 @@ class templater { @@ -923,7 +925,7 @@ class templater {
void
run_substitution_plugins(std::string &text,
const std::unordered_map<std::string, std::string> &properties, std::optional<const std::unordered_map<fs::path, blog_item, pathHash>> pages, bool allow_recursion)
const std::unordered_map<std::string, std::string> &properties, const std::optional<const std::unordered_map<fs::path, blog_item, pathHash>> &pages, bool allow_recursion)
{
std::string::size_type next = text.find(TEMPLATE_CODE_START, 0);

Loading…
Cancel
Save