diff --git a/src/odr/html_service.cpp b/src/odr/html_service.cpp
index 5a5b9f0b..42b7619d 100644
--- a/src/odr/html_service.cpp
+++ b/src/odr/html_service.cpp
@@ -48,16 +48,11 @@ const HtmlResourceLocator &HtmlFragment::resource_locator() const {
return m_impl->resource_locator();
}
-HtmlResources HtmlFragment::write_fragment(std::ostream &os) const {
+void HtmlFragment::write_fragment(std::ostream &os,
+ HtmlResources &resources) const {
internal::html::HtmlWriter out(os, config());
- auto internal_resources = m_impl->write_fragment(out);
-
- HtmlResources resources;
- for (const auto &[resource, location] : internal_resources) {
- resources.emplace_back(HtmlResource(resource), location);
- }
- return resources;
+ m_impl->write_fragment(out, resources);
}
HtmlResources HtmlFragment::write_document(std::ostream &os) const {
diff --git a/src/odr/html_service.hpp b/src/odr/html_service.hpp
index 0a89fd3e..e1388b90 100644
--- a/src/odr/html_service.hpp
+++ b/src/odr/html_service.hpp
@@ -57,7 +57,7 @@ class HtmlFragment final {
[[nodiscard]] const HtmlConfig &config() const;
[[nodiscard]] const HtmlResourceLocator &resource_locator() const;
- HtmlResources write_fragment(std::ostream &os) const;
+ void write_fragment(std::ostream &os, HtmlResources &resources) const;
HtmlResources write_document(std::ostream &os) const;
diff --git a/src/odr/internal/abstract/html_service.hpp b/src/odr/internal/abstract/html_service.hpp
index abacf03d..bc6d6ee1 100644
--- a/src/odr/internal/abstract/html_service.hpp
+++ b/src/odr/internal/abstract/html_service.hpp
@@ -36,7 +36,8 @@ class HtmlFragment {
[[nodiscard]] virtual const HtmlConfig &config() const = 0;
[[nodiscard]] virtual const HtmlResourceLocator &resource_locator() const = 0;
- virtual HtmlResources write_fragment(html::HtmlWriter &out) const = 0;
+ virtual void write_fragment(html::HtmlWriter &out,
+ HtmlResources &resources) const = 0;
virtual HtmlResources write_document(html::HtmlWriter &out) const = 0;
};
diff --git a/src/odr/internal/html/document.cpp b/src/odr/internal/html/document.cpp
index dbce8d3c..b0b3f491 100644
--- a/src/odr/internal/html/document.cpp
+++ b/src/odr/internal/html/document.cpp
@@ -154,7 +154,7 @@ class HtmlServiceImpl : public HtmlService {
front(m_document, state);
for (const auto &fragment : fragments()) {
- fragment->write_fragment(out);
+ fragment->write_fragment(out, resources);
}
back(m_document, state);
@@ -179,7 +179,7 @@ class HtmlFragmentBase : public HtmlFragment {
WritingState state(out, config(), resource_locator(), resources);
front(m_document, state);
- write_fragment(out);
+ write_fragment(out, resources);
back(m_document, state);
return resources;
@@ -196,9 +196,7 @@ class TextHtmlFragment final : public HtmlFragmentBase {
: HtmlFragmentBase("document", std::move(document), std::move(config),
std::move(resource_locator)) {}
- HtmlResources write_fragment(HtmlWriter &out) const final {
- HtmlResources resources;
-
+ void write_fragment(HtmlWriter &out, HtmlResources &resources) const final {
WritingState state(out, config(), resource_locator(), resources);
auto root = m_document.root_element();
@@ -224,8 +222,6 @@ class TextHtmlFragment final : public HtmlFragmentBase {
translate_children(element.children(), state);
out.write_element_end("div");
}
-
- return resources;
}
};
@@ -237,14 +233,10 @@ class SlideHtmlFragment final : public HtmlFragmentBase {
std::move(resource_locator)),
m_slide{slide} {}
- HtmlResources write_fragment(HtmlWriter &out) const final {
- HtmlResources resources;
-
+ void write_fragment(HtmlWriter &out, HtmlResources &resources) const final {
WritingState state(out, config(), resource_locator(), resources);
html::translate_slide(m_slide, state);
-
- return resources;
}
private:
@@ -259,14 +251,10 @@ class SheetHtmlFragment final : public HtmlFragmentBase {
std::move(resource_locator)),
m_sheet{sheet} {}
- HtmlResources write_fragment(HtmlWriter &out) const final {
- HtmlResources resources;
-
+ void write_fragment(HtmlWriter &out, HtmlResources &resources) const final {
WritingState state(out, config(), resource_locator(), resources);
translate_sheet(m_sheet, state);
-
- return resources;
}
private:
@@ -281,14 +269,10 @@ class PageHtmlFragment final : public HtmlFragmentBase {
std::move(resource_locator)),
m_page{page} {}
- HtmlResources write_fragment(HtmlWriter &out) const final {
- HtmlResources resources;
-
+ void write_fragment(HtmlWriter &out, HtmlResources &resources) const final {
WritingState state(out, config(), resource_locator(), resources);
html::translate_page(m_page, state);
-
- return resources;
}
private: