Merge lp:~zorba-coders/zorba/concat_operator into lp:zorba

Proposed by William Candillon
Status: Superseded
Proposed branch: lp:~zorba-coders/zorba/concat_operator
Merge into: lp:zorba
Diff against target: 31 lines (+20/-1)
1 file modified
src/compiler/translator/translator.cpp (+20/-1)
To merge this branch: bzr merge lp:~zorba-coders/zorba/concat_operator
Reviewer Review Type Date Requested Status
Markos Zaharioudakis Pending
Matthias Brantner Pending
Review via email: mp+94869@code.launchpad.net

This proposal has been superseded by a proposal from 2012-02-29.

Commit message

Optimize iterator generation for the concat operator.

Description of the change

 Optimize iterator generation for the concat operator.

To post a comment you must log in.
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Revision history for this message
Markos Zaharioudakis (markos-za) wrote :

A small code improvement: rather thah doing a dynamic_cast to check if an expr is an fo_expr, use the get_expr_kind() method. So, the code would look like this:

if (right->get_expr_kind() == fo_expr_kind)
{
  fo_expr* lfoExpr = static_cast<fo_expr*>(right.getp());
  etc....;
}

Also, please respect the coding style of the files you update. In this case, put the "{" in a separate line.

10674. By William Candillon

Improvement in the concat expr casting.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/compiler/translator/translator.cpp'
2--- src/compiler/translator/translator.cpp 2012-02-19 19:43:28 +0000
3+++ src/compiler/translator/translator.cpp 2012-02-27 22:07:44 +0000
4@@ -9401,7 +9401,26 @@
5 expr_t right = pop_nodestack();
6 expr_t left = pop_nodestack();
7 concat_args.push_back(left);
8- concat_args.push_back(right);
9+
10+ //If the right leaf is the concat expr,
11+ //we add directly its leafs to the new concat expr.
12+ fo_expr* lFoExpr = dynamic_cast<fo_expr*>(right.getp());
13+ bool rightLeafIsConcatExpr = false;
14+ if(lFoExpr != NULL) {
15+ if(lFoExpr->get_func() == GET_BUILTIN_FUNCTION(FN_CONCAT_N)) {
16+ rightLeafIsConcatExpr = true;
17+ csize i = 0;
18+ for(i = 0; i < lFoExpr->num_args(); ++i)
19+ {
20+ concat_args.push_back(lFoExpr->get_arg(i));
21+ }
22+ }
23+ }
24+
25+ if(!rightLeafIsConcatExpr){
26+ concat_args.push_back(right);
27+ }
28+
29 rchandle<expr> concat = new fo_expr(theRootSctx, loc, GET_BUILTIN_FUNCTION(FN_CONCAT_N), concat_args);
30 push_nodestack(concat);
31 }

Subscribers

People subscribed via source and target branches