[Beignet] [PATCH 1/7] add helper functions in ir::Constant and ir::ConstantSet

Xing, Homer homer.xing at intel.com
Fri Apr 26 19:07:36 PDT 2013


Hoho, maybe something changed. 

I will try it, if no compiler error from my side, I will send version three.

-----Original Message-----
From: Lu, Guanqun 
Sent: Saturday, April 27, 2013 10:05 AM
To: Xing, Homer; beignet at lists.freedesktop.org
Subject: RE: [Beignet] [PATCH 1/7] add helper functions in ir::Constant and ir::ConstantSet

Fortunately, I don't see a compiler error. :)

> -----Original Message-----
> From: beignet-bounces+guanqun.lu=intel.com at lists.freedesktop.org
> [mailto:beignet-bounces+guanqun.lu=intel.com at lists.freedesktop.org] On 
> Behalf Of Xing, Homer
> Sent: Saturday, April 27, 2013 9:35 AM
> To: beignet at lists.freedesktop.org
> Subject: Re: [Beignet] [PATCH 1/7] add helper functions in 
> ir::Constant and ir::ConstantSet
> 
> Thanks for telling me another way. Looks cool. But I am afraid your 
> way does not work. Because you try to return a reference of a local variable.
> 
> If you don't believe, try that way by yourself, then you will see a compile error.
> 
> -----Original Message-----
> From: Lu, Guanqun
> Sent: Saturday, April 27, 2013 9:21 AM
> To: Xing, Homer; beignet at lists.freedesktop.org
> Subject: RE: [Beignet] [PATCH 1/7] add helper functions in 
> ir::Constant and ir::ConstantSet
> 
> > +    /*! Get a special constant */
> > +    Constant& getConstant(const std::string & name) {
> > +      size_t i = 0;
> > +      for (auto c : constants) {
> > +        if (c.getName() == name)
> > +          return constants[i];
> > +        i ++;
> > +      }
> 
> > what the point of using 'i' here? I dont' think it's necessary.
> 
> Hi, see this: "return constants[i];"
> 
> [guanqun] then you can use
> 
> for (auto &c : constants) {
>   if (c.getName() == name)
>      return c;
> 
> much simpler. :)  you really don't need an extra i in this block.
> 
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list