Skip to content

Commit

Permalink
CodeGen.m: Remove DefFn from some functions
Browse files Browse the repository at this point in the history
These are called very frequently and using DefFn for them leads to a
performance penalty.
  • Loading branch information
ianhinder committed Mar 10, 2014
1 parent 48a8272 commit 7c05bb0
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions Tools/CodeGen/CodeGen.m
Expand Up @@ -60,20 +60,15 @@

(* Code generation utilities; not specific to any language *)

DefFn[
CheckBlock[s_String] := s];
CheckBlock[s_String] := s;

DefFn[
CheckBlock[a_?AtomQ] := a];
CheckBlock[a_?AtomQ] := a;

DefFn[
CheckBlock[l_List] := Map[CheckBlock, l]];
CheckBlock[l_List] := Map[CheckBlock, l];

DefFn[
CheckBlock[b_CodeBlock] := CheckBlock[CodeBlockContents[b]]];
CheckBlock[b_CodeBlock] := CheckBlock[CodeBlockContents[b]];

DefFn[
FlattenBlock[b_] :=
FlattenBlock[b_] :=
Module[
{flattenBlock},
flattenBlock[x_String] := x;
Expand All @@ -83,7 +78,7 @@
flattenBlock[x_] := ThrowError["Invalid arguments to flattenBlock: ", c];

CheckBlock[b];
flattenBlock[b]]];
flattenBlock[b]];

DefFn[
IndentBlock[block:CodeGenBlock] :=
Expand Down

0 comments on commit 7c05bb0

Please sign in to comment.