From 4685a3e5a8ad3a4e519b8e3645922c9df2095f62 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Thu, 31 Mar 2011 13:03:29 +0000 Subject: [PATCH] Given how we are using this exclusion list, it makes more sense for it to be a set. Not that speed will really be an issue here, but.... git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38178 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Buffer.cpp | 6 +++--- src/Converter.cpp | 14 ++++++-------- src/Converter.h | 3 ++- src/Graph.cpp | 4 ++-- src/Graph.h | 3 ++- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 70159fa473..88200f16dc 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -3712,10 +3712,10 @@ bool Buffer::isExportable(string const & format) const vector Buffer::exportableFormats(bool only_viewable) const { vector const backs = backends(); - vector excludes; + set excludes; if (params().useNonTeXFonts) { - excludes.push_back("latex"); - excludes.push_back("pdflatex"); + excludes.insert("latex"); + excludes.insert("pdflatex"); } vector result = theConverters().getReachable(backs[0], only_viewable, true, excludes); diff --git a/src/Converter.cpp b/src/Converter.cpp index d32f5bd097..0f0f4b44eb 100644 --- a/src/Converter.cpp +++ b/src/Converter.cpp @@ -691,16 +691,14 @@ Converters::getReachableTo(string const & target, bool const clear_visited) vector const Converters::getReachable(string const & from, bool const only_viewable, - bool const clear_visited, vector const & excludes) + bool const clear_visited, set const & excludes) { - vector excluded_numbers(excludes.size()); + set excluded_numbers;; - vector::const_iterator sit = excludes.begin(); - vector::const_iterator const end = excludes.end(); - vector::iterator it = excluded_numbers.begin(); - for ( ; sit != end; ++sit, ++it) { - *it = formats.getNumber(*sit); - } + set::const_iterator sit = excludes.begin(); + set::const_iterator const end = excludes.end(); + for (; sit != end; ++sit) + excluded_numbers.insert(formats.getNumber(*sit)); vector const & reachables = G_.getReachable(formats.getNumber(from), diff --git a/src/Converter.h b/src/Converter.h index 6e09352acc..13dc1471f3 100644 --- a/src/Converter.h +++ b/src/Converter.h @@ -16,6 +16,7 @@ #include "OutputParams.h" #include +#include #include @@ -101,7 +102,7 @@ public: std::vector const getReachable(std::string const & from, bool only_viewable, bool clear_visited, - std::vector const & excludes = std::vector()); + std::set const & excludes = std::set()); std::vector importableFormats(); std::vector exportableFormats(bool only_viewable); diff --git a/src/Graph.cpp b/src/Graph.cpp index fb7edbd34b..97427bcf1a 100644 --- a/src/Graph.cpp +++ b/src/Graph.cpp @@ -83,7 +83,7 @@ Graph::EdgePath const Graph::EdgePath const Graph::getReachable(int from, bool only_viewable, - bool clear_visited, vector excludes) + bool clear_visited, set excludes) { EdgePath result; queue Q; @@ -111,7 +111,7 @@ Graph::EdgePath const int const cv = (*cit)->to; if (!vertices_[cv].visited) { vertices_[cv].visited = true; - if (find(excludes.begin(), excludes.end(), cv) == excludes.end()) + if (excludes.find(cv) == excludes.end()) Q.push(cv); } } diff --git a/src/Graph.h b/src/Graph.h index 1518677b39..50d8bf855d 100644 --- a/src/Graph.h +++ b/src/Graph.h @@ -16,6 +16,7 @@ #include #include +#include #include @@ -33,7 +34,7 @@ public: EdgePath const getReachableTo(int to, bool clear_visited); /// \return a vector of the reachable vertices, avoiding all "excludes" EdgePath const getReachable(int from, bool only_viewable, - bool clear_visited, std::vector excludes = std::vector()); + bool clear_visited, std::set excludes = std::set()); /// can "from" be reached from "to"? bool isReachable(int from, int to); /// find a path from "from" to "to". always returns one of the