Browse Source

Made use of map/set instead of unordered_map/unordered_set where appropriate

merge-requests/389/head
eidheim 8 years ago
parent
commit
6a7a059458
  1. 1
      src/git.cc
  2. 1
      src/git.h
  3. 9
      src/source.cc
  4. 5
      src/source.h
  5. 4
      src/source_clang.cc
  6. 3
      src/source_clang.h
  7. 8
      src/source_language_protocol.h

1
src/git.cc

@ -1,5 +1,6 @@
#include "git.h" #include "git.h"
#include <cstring> #include <cstring>
#include <unordered_map>
bool Git::initialized=false; bool Git::initialized=false;
std::mutex Git::mutex; std::mutex Git::mutex;

1
src/git.h

@ -4,7 +4,6 @@
#include <memory> #include <memory>
#include <iostream> #include <iostream>
#include <unordered_set> #include <unordered_set>
#include <unordered_map>
#include <vector> #include <vector>
#include <giomm.h> #include <giomm.h>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>

9
src/source.cc

@ -13,6 +13,7 @@
#include <boost/spirit/home/qi/operator.hpp> #include <boost/spirit/home/qi/operator.hpp>
#include <boost/spirit/home/qi/string.hpp> #include <boost/spirit/home/qi/string.hpp>
#include <iostream> #include <iostream>
#include <map>
#include <numeric> #include <numeric>
#include <set> #include <set>
#include <regex> #include <regex>
@ -111,8 +112,8 @@ std::string Source::FixIt::string(const Glib::RefPtr<Gtk::TextBuffer> &buffer) {
////////////// //////////////
//// View //// //// View ////
////////////// //////////////
std::unordered_set<Source::View*> Source::View::non_deleted_views; std::set<Source::View*> Source::View::non_deleted_views;
std::unordered_set<Source::View*> Source::View::views; std::set<Source::View*> Source::View::views;
Source::View::View(const boost::filesystem::path &file_path, const Glib::RefPtr<Gsv::Language> &language, bool is_generic_view): BaseView(file_path, language), SpellCheckView(file_path, language), DiffView(file_path, language), parsed(true) { Source::View::View(const boost::filesystem::path &file_path, const Glib::RefPtr<Gsv::Language> &language, bool is_generic_view): BaseView(file_path, language), SpellCheckView(file_path, language), DiffView(file_path, language), parsed(true) {
non_deleted_views.emplace(this); non_deleted_views.emplace(this);
@ -2740,8 +2741,8 @@ bool Source::View::on_motion_notify_event(GdkEventMotion *event) {
} }
std::pair<char, unsigned> Source::View::find_tab_char_and_size() { std::pair<char, unsigned> Source::View::find_tab_char_and_size() {
std::unordered_map<char, size_t> tab_chars; std::map<char, size_t> tab_chars;
std::unordered_map<unsigned, size_t> tab_sizes; std::map<unsigned, size_t> tab_sizes;
auto iter=get_buffer()->begin(); auto iter=get_buffer()->begin();
long tab_count=-1; long tab_count=-1;
long last_tab_count=0; long last_tab_count=0;

5
src/source.h

@ -7,6 +7,7 @@
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include <set>
#include <tuple> #include <tuple>
namespace Source { namespace Source {
@ -50,8 +51,8 @@ namespace Source {
class View : public SpellCheckView, public DiffView { class View : public SpellCheckView, public DiffView {
public: public:
static std::unordered_set<View*> non_deleted_views; static std::set<View*> non_deleted_views;
static std::unordered_set<View*> views; static std::set<View*> views;
View(const boost::filesystem::path &file_path, const Glib::RefPtr<Gsv::Language> &language, bool is_generic_view=false); View(const boost::filesystem::path &file_path, const Glib::RefPtr<Gsv::Language> &language, bool is_generic_view=false);
~View() override; ~View() override;

4
src/source_clang.cc

@ -216,8 +216,8 @@ void Source::ClangViewParse::soft_reparse(bool delayed) {
}, delayed?1000:0); }, delayed?1000:0);
} }
const std::unordered_map<int, std::string> &Source::ClangViewParse::clang_types() { const std::map<int, std::string> &Source::ClangViewParse::clang_types() {
static std::unordered_map<int, std::string> types{ static std::map<int, std::string> types{
{8, "def:function"}, {8, "def:function"},
{21, "def:function"}, {21, "def:function"},
{22, "def:identifier"}, {22, "def:identifier"},

3
src/source_clang.h

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <thread> #include <thread>
#include <atomic> #include <atomic>
#include <map>
#include <mutex> #include <mutex>
#include <set> #include <set>
#include "clangmm.h" #include "clangmm.h"
@ -43,7 +44,7 @@ namespace Source {
private: private:
Glib::ustring parse_thread_buffer; Glib::ustring parse_thread_buffer;
static const std::unordered_map<int, std::string> &clang_types(); static const std::map<int, std::string> &clang_types();
void update_syntax(); void update_syntax();
std::map<int, Glib::RefPtr<Gtk::TextTag>> syntax_tags; std::map<int, Glib::RefPtr<Gtk::TextTag>> syntax_tags;

8
src/source_language_protocol.h

@ -6,8 +6,8 @@
#include <list> #include <list>
#include <mutex> #include <mutex>
#include <sstream> #include <sstream>
#include <unordered_map> #include <map>
#include <unordered_set> #include <set>
namespace Source { namespace Source {
class LanguageProtocolView; class LanguageProtocolView;
@ -46,7 +46,7 @@ namespace LanguageProtocol {
Capabilities capabilities; Capabilities capabilities;
std::unordered_set<Source::LanguageProtocolView *> views; std::set<Source::LanguageProtocolView *> views;
std::mutex views_mutex; std::mutex views_mutex;
std::mutex initialize_mutex; std::mutex initialize_mutex;
@ -61,7 +61,7 @@ namespace LanguageProtocol {
size_t message_id = 1; size_t message_id = 1;
std::unordered_map<size_t, std::pair<Source::LanguageProtocolView*, std::function<void(const boost::property_tree::ptree &, bool error)>>> handlers; std::map<size_t, std::pair<Source::LanguageProtocolView*, std::function<void(const boost::property_tree::ptree &, bool error)>>> handlers;
std::vector<std::thread> timeout_threads; std::vector<std::thread> timeout_threads;
std::mutex timeout_threads_mutex; std::mutex timeout_threads_mutex;

Loading…
Cancel
Save