about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2017-05-30 07:34:58 -0700
committerKartik K. Agaram <vc@akkartik.com>2017-05-31 16:43:05 -0700
commit6424e19999499719014395cc2ecd025e8efb8a91 (patch)
treed06a14b0b05b835b58632d1b1d7c458eb9c1bc84
parent2c678a4e1d7f97c862342ee19cf2d6ee6e901d85 (diff)
downloadmu-6424e19999499719014395cc2ecd025e8efb8a91.tar.gz
3898
There seems to be some chance of speed-up when I inline these functions.
However, it's not a clear enough signal to justify improving the `build`
script to handle the `inline` keyword.

Current timing experiments:
              Before                                After
ubuntu 1GB    9:22,8:48,8:51,9:16,9:17,8:36,9:05    8:55,8:41,8:15,8:27,8:29,8:54,9:29
OS X 8GB      4:05,4:00,4:18,4:09,3:40,3:51,3:56    3:58,3:52,4:01,4:13,4:16,4:31,4:13
-rw-r--r--026call.cc48
1 files changed, 14 insertions, 34 deletions
diff --git a/026call.cc b/026call.cc
index e813004d..a82917f1 100644
--- a/026call.cc
+++ b/026call.cc
@@ -67,42 +67,22 @@ routine::routine(recipe_ordinal r) {
   // End routine Constructor
 }
 
-:(code)
-call& current_call() {
-  return Current_routine->calls.front();
-}
-
 //:: now update routine's helpers
 
-:(replace{} "int& current_step_index()")
-int& current_step_index() {
-  assert(!Current_routine->calls.empty());
-  return current_call().running_step_index;
-}
-:(replace{} "recipe_ordinal currently_running_recipe()")
-recipe_ordinal currently_running_recipe() {
-  assert(!Current_routine->calls.empty());
-  return current_call().running_recipe;
-}
-:(replace{} "const string& current_recipe_name()")
-const string& current_recipe_name() {
-  assert(!Current_routine->calls.empty());
-  return get(Recipe, current_call().running_recipe).name;
-}
-:(replace{} "const recipe& current_recipe()")
-const recipe& current_recipe() {
-  assert(!Current_routine->calls.empty());
-  return get(Recipe, current_call().running_recipe);
-}
-:(replace{} "const instruction& current_instruction()")
-const instruction& current_instruction() {
-  assert(!Current_routine->calls.empty());
-  return to_instruction(current_call());
-}
-:(code)
-const instruction& to_instruction(const call& call) {
-  return get(Recipe, call.running_recipe).steps.at(call.running_step_index);
-}
+:(delete{} "int& current_step_index()")
+:(delete{} "recipe_ordinal currently_running_recipe()")
+:(delete{} "const string& current_recipe_name()")
+:(delete{} "const recipe& current_recipe()")
+:(delete{} "const instruction& current_instruction()")
+
+:(before "End Includes")
+#define current_call() Current_routine->calls.front()
+#define current_step_index() current_call().running_step_index
+#define currently_running_recipe() current_call().running_recipe
+#define current_recipe() get(Recipe, currently_running_recipe())
+#define current_recipe_name() current_recipe().name
+#define to_instruction(call) get(Recipe, (call).running_recipe).steps.at((call).running_step_index)
+#define current_instruction() to_instruction(current_call())
 
 :(after "Defined Recipe Checks")
 // not a primitive; check that it's present in the book of recipes