[m-rev.] diff: avoid extra traversal in deep_profiling.m

Paul Bone pbone at csse.unimelb.edu.au
Mon Dec 24 11:39:52 AEDT 2007


On 24/12/2007, at 11:00 AM, Zoltan Somogyi wrote:

> This has already been reviewed by Paul Bone in person.
>
> Zoltan.
>
> ws0/deep_profiling.m:
> 	Avoid an extra pass through conjunctions by flattening conjunctions
> 	in place.
>
> cvs diff: Diffing .
> Index: deep_profiling.m
> ===================================================================
> RCS file: /home/mercury/mercury1/repository/mercury/compiler/ 
> deep_profiling.m,v
> retrieving revision 1.70
> diff -u -b -r1.70 deep_profiling.m
> --- deep_profiling.m	19 Dec 2007 03:10:48 -0000	1.70
> +++ deep_profiling.m	21 Dec 2007 03:33:39 -0000
> @@ -34,7 +34,6 @@
>  :- import_module check_hlds.mode_util.
>  :- import_module check_hlds.type_util.
>  :- import_module hlds.code_model.
> -:- import_module hlds.goal_util.
>  :- import_module hlds.hlds_goal.
>  :- import_module hlds.hlds_pred.
>  :- import_module hlds.hlds_rtti.
> @@ -884,10 +883,9 @@
>          AddedImpurity = no
>      ;
>          GoalExpr0 = conj(ConjType, Goals0),
> -        deep_prof_transform_conj(0, Path, Goals0, Goals1,  
> AddedImpurity,
> -            !DeepInfo),
> +        deep_prof_transform_conj(0, ConjType, Path, Goals0, Goals,
> +            AddedImpurity, !DeepInfo),
>          add_impurity_if_needed(AddedImpurity, GoalInfo0, GoalInfo),
> -        flatten_conj(Goals1, Goals),
>          GoalExpr = conj(ConjType, Goals),
>          Goal = hlds_goal(GoalExpr, GoalInfo)
>      ;
> @@ -984,18 +982,28 @@
>              "deep_prof_transform_goal: shorthand should have gone  
> by now")
>      ).
>
> -:- pred deep_prof_transform_conj(int::in, goal_path::in,
> +:- pred deep_prof_transform_conj(int::in,
> +    conj_type::in, goal_path::in,
>      list(hlds_goal)::in, list(hlds_goal)::out, bool::out,
>      deep_info::in, deep_info::out) is det.
>
> -deep_prof_transform_conj(_, _, [], [], no, !DeepInfo).
> -deep_prof_transform_conj(N, Path, [Goal0 | Goals0], [Goal | Goals],
> +deep_prof_transform_conj(_, _, _, [], [], no, !DeepInfo).
> +deep_prof_transform_conj(N, ConjType, Path, [Goal0 | Goals0], Goals,
>          AddedImpurity, !DeepInfo) :-
>      N1 = N + 1,
>      deep_prof_transform_goal(cord.snoc(Path, step_conj(N1)),  
> Goal0, Goal,
>          AddedImpurityFirst, !DeepInfo),
> -    deep_prof_transform_conj(N1, Path, Goals0, Goals,  
> AddedImpurityLater,
> -        !DeepInfo),
> +    deep_prof_transform_conj(N1, ConjType, Path, Goals0,
> +        TailGoals, AddedImpurityLater, !DeepInfo),
> +    Goal = hlds_goal(GoalExpr, _),
> +    (
> +        GoalExpr = conj(plain_conj, Conjunct),

s/Conjunct/Conjuncts

I missed this when I reviewed it earlier.

> +        ConjType = plain_conj
> +    ->
> +        Goals = Conjuncts ++ TailGoals
> +    ;
> +        Goals = [Goal | TailGoals]
> +    ),
>      bool.or(AddedImpurityFirst, AddedImpurityLater, AddedImpurity).
>

Thanks.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20071224/401809ff/attachment.sig>


More information about the reviews mailing list