From 4f8948b8f67d26726a2e53c9afe1a110c037ce4b Mon Sep 17 00:00:00 2001
From: Arnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Date: Mon, 13 Dec 2010 10:48:41 +0100
Subject: [PATCH 1/1] Wip++...

* use <tr1/unordered_map> for process::rev_neigh
* update setlocalversion to use -dirty suffix
---
 process.cpp     |  4 ++++
 process.h       | 16 +++++++++++++---
 setlocalversion |  7 +++++++
 3 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/process.cpp b/process.cpp
index 1a9066d..e1232f2 100644
--- a/process.cpp
+++ b/process.cpp
@@ -49,6 +49,10 @@ process::process(int argc, char* argv[])
     print_loads(logp);
 }
 
+process::~process()
+{
+}
+
 int process::run()
 {
     bool one_more = true;
diff --git a/process.h b/process.h
index a49c6ef..5802426 100644
--- a/process.h
+++ b/process.h
@@ -1,8 +1,17 @@
 #ifndef PROCESS_H
 #define PROCESS_H
 
-#include <map>
+#define USE_UNORDERED_MAP 1
+//#undef USE_UNORDERED_MAP
+
 #include <vector>
+#ifdef USE_UNORDERED_MAP
+#  include <tr1/unordered_map>
+#  define MAP_TEMPLATE std::tr1::unordered_map
+#else
+#  include <map>
+#  define MAP_TEMPLATE std::map
+#endif
 #include <msg/msg.h>
 #include "communicator.h"
 #include "neighbor.h"
@@ -10,12 +19,13 @@
 class process {
 public:
     process(int argc, char* argv[]);
-    ~process() { };
+    ~process();
     int run();
 
 private:
     std::vector<neighbor> neigh;
-    std::map<m_host_t, neighbor*> rev_neigh;
+    MAP_TEMPLATE<m_host_t, neighbor*> rev_neigh;
+    std::vector<neighbor*> pneigh;
 
     communicator comm;
     int ctrl_close_pending;
diff --git a/setlocalversion b/setlocalversion
index 43ac91a..221f868 100755
--- a/setlocalversion
+++ b/setlocalversion
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+# Inspired by linux-2.6/scripts/setlocalversion
+
 set -e
 
 FILE=localversion
@@ -11,6 +13,11 @@ compute_version()
     fi
     head=$(git rev-parse --verify --short HEAD)
     printf "~git-%s" "$head"
+    # Check for uncommitted changes
+    if git diff-index --name-only HEAD | read dummy; then
+        printf '%s' "-dirty"
+    fi
+
 }
 
 [ -f "$FILE" ] || touch "$FILE"
-- 
2.39.5