# HG changeset patch # User Mike Pavone # Date 1288314284 14400 # Node ID 7361d70fbba69c42faaf07c089080741394daff5 # Parent 1af91ceaaf4970b73e54a328cd51b9da76fc5d03 Improve comparison performance by using a constant rather than building a new result object each time diff -r 1af91ceaaf49 -r 7361d70fbba6 number_c.rhope --- a/number_c.rhope Thu Oct 28 21:04:12 2010 -0400 +++ b/number_c.rhope Thu Oct 28 21:04:44 2010 -0400 @@ -29,16 +29,18 @@ ]Set Input Type[type inst, 0] ]Set Input Type[type inst, 1] ]Set Output Type[Type Instance["Boolean"], 0] - ]Register Constant["Blueprint_Boolean", Type Instance["Boolean"]] - ]Call["Build", [()]Append[Constant["Blueprint_Boolean"]]] - ]Move[Result[0], "out"] + ]Register Constant["Boolean_Yes", Yes] + ]Register Constant["Boolean_No", No] + ]Allocate Var["compres", [Type Instance["Int32"]]Set Variant["Naked"]] ,ina <- [func]Read Field["a", "Num"] { ,inb <- [~]Read Field["b", "Num"] - { ,outa <- [~]Write Field["out", "Val"] - { after op <- [backend func]Call[~, ina, inb, outa] }}} + { after op <- [backend func]Call[~, ina, inb, "compres"] }} + + [after op]Do If["compres", [[after op]Instruction Stream]Move[Constant["Boolean_Yes"], "out"]] + { after out <- [~]Do If[NotCond["compres"], [[after op]Instruction Stream]Move[Constant["Boolean_No"], "out"]] } - out <- [backend]Store Function[ [[after op]Release["a"]]Release["b"] ] + out <- [backend]Store Function[ [[after out]Release["a"]]Release["b"] ] } @@ -82,13 +84,15 @@ _Generate Number Methods[backend, type:out] { //Old crappy parser doesn't like Worker literals in List literals, work around for now - opmap <- [[[[[[() + opmap <- [[[[[[[[() ]Append[ [("+")]Append[Add[?]] ] ]Append[ [("-")]Append[Sub[?]] ] ]Append[ [("*")]Append[Multiply[?]] ] ]Append[ [("/")]Append[Divide[?]] ] ]Append[ [("LShift")]Append[DoLShift[?]] ] ]Append[ [("RShift")]Append[DoRShift[?]] ] + ]Append[ [("&")]Append[BitAnd[?]] ] + ]Append[ [("|")]Append[BitOr[?]] ] //(("+", Add[?]), ("-", Sub[?]), ("*", Multiply[?]), ("/", Divide[?]), ("LShift", DoLShift[?]), ("RShift", DoRShift[?])) compops <- [[[[[[() ]Append[ [("<")]Append[CompLess[?]] ] @@ -173,7 +177,7 @@ _Register Number Methods[program,type:out] { - methods <- ("+", "-", "*", "/", "LShift", "RShift") + methods <- ("+", "-", "*", "/", "LShift", "RShift", "&", "|") compmethods <- ("<", ">", "=", "<=", ">=", "!=") register <- Val[Register Number Method[?, ?, type]] Fold[[register]Set Input[3, type], program, methods]