[pan: 3/9] Assorted cleanups / reformats of code




commit 852f48c0e40fc90a6b035ea6362ddba6b6d703cc
Author: Thomas Tanner <thosrtanner googlemail com>
Date:   Sun Jun 12 20:18:40 2022 +0100

    Assorted cleanups / reformats of code

 pan/general/quark.cc          |  9 +++++----
 pan/general/quark.h           | 24 +++++++++++++++++-------
 pan/gui/group-prefs-dialog.cc |  8 --------
 pan/gui/post-ui.cc            | 27 +++++++++++++--------------
 4 files changed, 35 insertions(+), 33 deletions(-)
---
diff --git a/pan/general/quark.cc b/pan/general/quark.cc
index 5c84fb9..d647889 100644
--- a/pan/general/quark.cc
+++ b/pan/general/quark.cc
@@ -42,10 +42,11 @@ void
 Quark :: dump (std::ostream& o)
 {
   if (size()) {
-    o << "Existing Quarks: " << size() << ':' << std::endl;
-    for (lookup_t::const_iterator it(_lookup.begin()), e(_lookup.end()); it!=e; ++it)
-        o << "  [" << it->to_view() << "] (refcount " << it->refcount << ')' << std::endl;
-    o << std::endl;
+    o << "Existing Quarks: " << size() << ':' << "\n";
+    for (lookup_t::const_iterator it(_lookup.begin()), e(_lookup.end()); it!=e; ++it) {
+        o << "  [" << it->to_view() << "] (refcount " << it->refcount << ')' << "\n";
+    }
+    o << "\n";
   }
 }
 
diff --git a/pan/general/quark.h b/pan/general/quark.h
index bfa6769..1472bd8 100644
--- a/pan/general/quark.h
+++ b/pan/general/quark.h
@@ -77,8 +77,12 @@ namespace pan
         Impl (const StringView& v): refcount(0), len(v.len), str(const_cast<char*>(v.str)) {}
         StringView to_view () const { return StringView(str,len); }
         //wtf? bool operator() (const Impl& a, const Impl& b) const { return StringView(str,len) == 
StringView(b.str,b.len); }
-        bool operator== (const Impl& b) const { return StringView(str,len) == StringView(b.str,b.len); }
-        bool operator< (const Impl& b) const { return StringView(str,len) < StringView(b.str,b.len); }
+        bool operator== (const Impl& b) const {
+          return StringView(str,len) == StringView(b.str,b.len);
+        }
+        bool operator< (const Impl& b) const {
+          return StringView(str,len) < StringView(b.str,b.len);
+        }
       };
 
       struct StringViewHash
@@ -97,16 +101,17 @@ namespace pan
           const char * data (s.str);
           int len (s.len);
 
-          uint32_t tmp, hash=len;
           if (len <= 0 || data == NULL) return 0;
 
+          uint32_t hash = len;
+
           int rem = len & 3;
           len >>= 2;
 
           /* Main loop */
           for (;len > 0; len--) {
               hash  += get16bits (data);
-              tmp    = (get16bits (data+2) << 11) ^ hash;
+              uint32_t tmp  = (get16bits (data + 2) << 11) ^ hash;
               hash   = (hash << 16) ^ tmp;
               data  += 2*sizeof (uint16_t);
               hash  += hash >> 11;
@@ -114,16 +119,21 @@ namespace pan
 
           /* Handle end cases */
           switch (rem) {
-              case 3: hash += get16bits (data);
+              case 3:
+                hash += get16bits (data);
                       hash ^= hash << 16;
                       hash ^= data[sizeof (uint16_t)] << 18;
                       hash += hash >> 11;
                       break;
-              case 2: hash += get16bits (data);
+
+              case 2:
+                hash += get16bits (data);
                       hash ^= hash << 11;
                       hash += hash >> 17;
                       break;
-              case 1: hash += *data;
+
+              case 1:
+                hash += *data;
                       hash ^= hash << 10;
                       hash += hash >> 1;
           }
diff --git a/pan/gui/group-prefs-dialog.cc b/pan/gui/group-prefs-dialog.cc
index 8ed7a0a..ffea63d 100644
--- a/pan/gui/group-prefs-dialog.cc
+++ b/pan/gui/group-prefs-dialog.cc
@@ -221,14 +221,6 @@ namespace
     return w;
   }
 
-//  void color_set_cb (GtkColorButton* b, gpointer p)
-//  {
-//    GroupPrefsDialog* dialog = static_cast<GroupPrefsDialog*>(p);
-//       GdkColor col;
-//       gtk_color_button_get_color (b, &col);
-//       dialog->_color = col;
-//  }
-
   void color_set_cb (GtkColorButton* b, gpointer p)
   {
     GroupPrefsDialog* dialog = static_cast<GroupPrefsDialog*>(p);
diff --git a/pan/gui/post-ui.cc b/pan/gui/post-ui.cc
index 192a7a7..8eace4d 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -154,17 +154,26 @@ PostUI:: update_filequeue_label (GtkTreeSelection *selection)
 {
     tasks_t tasks(get_selected_files());
 
-    if (tasks.empty())
+    if (tasks.empty()) {
       _upload_queue.get_all_tasks(tasks);
+    }
 
     char str[512];
     long kb(0);
     foreach (PostUI::tasks_t, tasks, it)
     {
-      TaskUpload * task (dynamic_cast<TaskUpload*>(*it));
-      if (task) kb += task->_bytes/1024;
+      TaskUpload * task(dynamic_cast<TaskUpload*>(*it));
+      if (task) {
+        kb += task->_bytes / 1024;
+      }
     }
-    g_snprintf(str,sizeof(str), _("Upload queue: %lu tasks, %ld KB (~ %.2f MB) total."), tasks.size(), kb, 
kb/1024.0f);
+    g_snprintf(
+      str,
+      sizeof(str),
+      _("Upload queue: %lu tasks, %ld KB (~ %.2f MB) total."),
+      tasks.size(),
+      kb,
+      kb / 1024.0f);
     gtk_label_set_text (GTK_LABEL(_filequeue_label), str);
 }
 
@@ -315,16 +324,6 @@ PostUI :: set_spellcheck_enabled (bool enabled)
       }
     }
 #endif // GTKSPELL_VERSION
-#else // HAVE_GTKSPELL
-    // disable this for now, it is annoying
-//    GtkWidget * w = gtk_message_dialog_new_with_markup (
-//      GTK_WINDOW(_root),
-//      GTK_DIALOG_DESTROY_WITH_PARENT,
-//      GTK_MESSAGE_ERROR,
-//      GTK_BUTTONS_CLOSE,
-//      _("<b>Spellchecker not found!</b>\n \nWas this copy of Pan compiled with GtkSpell enabled?"));
-//    g_signal_connect_swapped (w, "response", G_CALLBACK (gtk_widget_destroy), w);
-//    gtk_widget_show_all (w);
 #endif // HAVE_GTKSPELL
   }
   else // disable


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]