about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-08-26 13:40:19 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-08-26 13:40:19 -0700
commit7fd010710c0a34ff103bec3fb271f0c207bfcc53 (patch)
tree710cec51fc102241ec540511a72a6ee4c52d3e87
parent029a3bdf53b523eded91a30177affdcace3bb2a1 (diff)
downloadmu-7fd010710c0a34ff103bec3fb271f0c207bfcc53.tar.gz
3259
Prefer preincrement operators wherever possible. Old versions of
compilers used to be better at optimizing them. Even if we don't care
about performance it's useful to make unary operators look like unary
operators wherever possible, and to distinguish the 'statement form'
which doesn't care about the value of the expression from the
postincrement which usually increments as a side-effect in some larger
computation (and so is worth avoiding except for some common idioms, or
perhaps even there).
-rw-r--r--011load.cc2
-rw-r--r--020run.cc4
-rw-r--r--034address.cc4
-rw-r--r--037abandon.cc2
-rw-r--r--038new_text.cc4
-rw-r--r--056shape_shifting_recipe.cc2
-rw-r--r--072scheduler.cc2
-rw-r--r--080display.cc10
-rw-r--r--085scenario_console.cc2
-rw-r--r--089scenario_filesystem.cc4
10 files changed, 18 insertions, 18 deletions
diff --git a/011load.cc b/011load.cc
index ca66a8f4..6aae80f9 100644
--- a/011load.cc
+++ b/011load.cc
@@ -127,7 +127,7 @@ bool next_instruction(istream& in, instruction* curr) {
     raise << "instruction prematurely ended with '<-'\n" << end();
     return false;
   }
-  curr->old_name = curr->name = *p;  p++;
+  curr->old_name = curr->name = *p;  ++p;
   // curr->operation will be set in a later layer
 
   for (; p != words.end(); ++p)
diff --git a/020run.cc b/020run.cc
index fd05f1d8..362d93a0 100644
--- a/020run.cc
+++ b/020run.cc
@@ -148,8 +148,8 @@ load_file_or_directory("core.mu");
 //? START_TRACING_UNTIL_END_OF_SCOPE
 if (argc > 1) {
   // skip argv[0]
-  argv++;
-  argc--;
+  ++argv;
+  --argc;
   // ignore argv past '--'; that's commandline args for 'main'
   while (argc > 0) {
     if (string(*argv) == "--") break;
diff --git a/034address.cc b/034address.cc
index a6ed554f..6a688240 100644
--- a/034address.cc
+++ b/034address.cc
@@ -285,10 +285,10 @@ case ALLOCATE: {
 :(code)
 int allocate(int size) {
   // include space for refcount
-  size++;
+  ++size;
   trace(9999, "mem") << "allocating size " << size << end();
 //?   Total_alloc += size;
-//?   Num_alloc++;
+//?   ++Num_alloc;
   // Allocate Special-cases
   // compute the region of memory to return
   // really crappy at the moment
diff --git a/037abandon.cc b/037abandon.cc
index 6195cdf6..d34a493b 100644
--- a/037abandon.cc
+++ b/037abandon.cc
@@ -28,7 +28,7 @@ map<int, int> free_list;
 void abandon(int address, const type_tree* payload_type, int payload_size) {
   trace(9999, "abandon") << "updating refcounts inside " << address << ": " << to_string(payload_type) << end();
 //?   Total_free += size;
-//?   Num_free++;
+//?   ++Num_free;
 //?   cerr << "abandon: " << size << '\n';
   // decrement any contained refcounts
   if (payload_type->name == "array") {
diff --git a/038new_text.cc b/038new_text.cc
index b3635331..ad0bb99a 100644
--- a/038new_text.cc
+++ b/038new_text.cc
@@ -35,7 +35,7 @@ int new_mu_string(const string& contents) {
   // allocate an array just large enough for it
   int string_length = unicode_length(contents);
 //?   Total_alloc += string_length+1;
-//?   Num_alloc++;
+//?   ++Num_alloc;
   int result = allocate(string_length+/*array size*/1);
   trace(9999, "mem") << "storing string refcount 0 in location " << result << end();
   put(Memory, result, 0);
@@ -124,7 +124,7 @@ int unicode_length(const string& s) {
 
 string read_mu_string(int address) {
   if (address == 0) return "";
-  address++;  // skip refcount
+  ++address;  // skip refcount
   int size = get_or_insert(Memory, address);
   if (size == 0) return "";
   ostringstream tmp;
diff --git a/056shape_shifting_recipe.cc b/056shape_shifting_recipe.cc
index a4485f6c..042ddb8f 100644
--- a/056shape_shifting_recipe.cc
+++ b/056shape_shifting_recipe.cc
@@ -194,7 +194,7 @@ int number_of_concrete_type_names(const type_tree* type) {
   if (!type) return 0;
   int result = 0;
   if (!type->name.empty() && !is_type_ingredient_name(type->name))
-    result++;
+    ++result;
   result += number_of_concrete_type_names(type->left);
   result += number_of_concrete_type_names(type->right);
   return result;
diff --git a/072scheduler.cc b/072scheduler.cc
index 9d99067c..7a63651b 100644
--- a/072scheduler.cc
+++ b/072scheduler.cc
@@ -137,7 +137,7 @@ int Next_routine_id = 1;
 Next_routine_id = 1;
 :(before "End routine Constructor")
 id = Next_routine_id;
-Next_routine_id++;
+++Next_routine_id;
 
 //: routines save the routine that spawned them
 :(before "End routine Fields")
diff --git a/080display.cc b/080display.cc
index 9619e5ab..f40b40c8 100644
--- a/080display.cc
+++ b/080display.cc
@@ -223,7 +223,7 @@ case MOVE_CURSOR_DOWN_ON_DISPLAY: {
   int h=tb_height();
   int height = (h >= 0) ? h : 0;
   if (Display_row < height-1) {
-    Display_row++;
+    ++Display_row;
     tb_set_cursor(Display_column, Display_row);
     if (Autodisplay) tb_present();
   }
@@ -241,7 +241,7 @@ case MOVE_CURSOR_UP_ON_DISPLAY: {
 :(before "End Primitive Recipe Implementations")
 case MOVE_CURSOR_UP_ON_DISPLAY: {
   if (Display_row > 0) {
-    Display_row--;
+    --Display_row;
     tb_set_cursor(Display_column, Display_row);
     if (Autodisplay) tb_present();
   }
@@ -261,7 +261,7 @@ case MOVE_CURSOR_RIGHT_ON_DISPLAY: {
   int w=tb_width();
   int width = (w >= 0) ? w : 0;
   if (Display_column < width-1) {
-    Display_column++;
+    ++Display_column;
     tb_set_cursor(Display_column, Display_row);
     if (Autodisplay) tb_present();
   }
@@ -279,7 +279,7 @@ case MOVE_CURSOR_LEFT_ON_DISPLAY: {
 :(before "End Primitive Recipe Implementations")
 case MOVE_CURSOR_LEFT_ON_DISPLAY: {
   if (Display_column > 0) {
-    Display_column--;
+    --Display_column;
     tb_set_cursor(Display_column, Display_row);
     if (Autodisplay) tb_present();
   }
@@ -293,7 +293,7 @@ else if (tb_is_active()) {
 }
 :(code)
 void move_cursor_to_start_of_next_line_on_display() {
-  if (Display_row < tb_height()-1) Display_row++;
+  if (Display_row < tb_height()-1) ++Display_row;
   else Display_row = 0;
   Display_column = 0;
   tb_set_cursor(Display_column, Display_row);
diff --git a/085scenario_console.cc b/085scenario_console.cc
index fc0e21cc..d18792af 100644
--- a/085scenario_console.cc
+++ b/085scenario_console.cc
@@ -273,7 +273,7 @@ int count_events(const recipe& r) {
     if (curr.name == "type")
       result += unicode_length(curr.ingredients.at(0).name);
     else
-      result++;
+      ++result;
   }
   return result;
 }
diff --git a/089scenario_filesystem.cc b/089scenario_filesystem.cc
index 65b56755..cef140de 100644
--- a/089scenario_filesystem.cc
+++ b/089scenario_filesystem.cc
@@ -195,12 +195,12 @@ void construct_filesystem_object(const map<string, string>& contents) {
     trace(9999, "mem") << "storing file name " << get(Memory, curr) << " in location " << curr << end();
     put(Memory, get(Memory, curr), 1);
     trace(9999, "mem") << "storing refcount 1 in location " << get(Memory, curr) << end();
-    curr++;
+    ++curr;
     put(Memory, curr, new_mu_string(p->second));
     trace(9999, "mem") << "storing file contents " << get(Memory, curr) << " in location " << curr << end();
     put(Memory, get(Memory, curr), 1);
     trace(9999, "mem") << "storing refcount 1 in location " << get(Memory, curr) << end();
-    curr++;
+    ++curr;
   }
   curr = filesystem_data_address+/*skip refcount*/1;
   put(Memory, curr, SIZE(contents));  // size of array