Hi,

On Fri, Feb 5, 2010 at 2:05 PM, Oleg Pronin <syber....@gmail.com> wrote:
> IMHO you are doing the right thing, but i can advice you a futher
> improvement and very important - perfomance boost for your module.
>
> You can do shorcuts shorter:
>     in setup_finalize of Catalyst:
>
>        foreach my $source ($schema->sources) {
>            next unless index($source, '::') == -1;
>            my $acc = "${source}RS";
>            $c->mk_group_accessors(inherited => $acc) unless $c->can($acc);
>            $c->$acc( scalar $schema->resultset($source) );
>        }
>
> You gain very short accesors (which cannon conflict due to 'RS' suffix)
> for example
>   $c->UserRS->single(...)
>   $c->ChatMessageRS->search(...)
>
> Plus - such accessors works MUCH MUCH faster than $schema->resultset because
> ->resultset method generates new empty resultset every time and this
> operation is quite hard for DBIC (why???!!!).
> With this accessors all empty resultsets has been already generated on start.

So if I understood your suggestion, I would cache the empty resultset
and reuse it on each invocation.

Nice.

I'll do that for the instance-based code I mentioned yesterday, but I
need to think how to do it properly for the class-based setup that I
have right now.

As for the code above, it bypasses nested sources. All my sources are
nested. Also the generated SourceRS methods are camel-cased, and I
prefer the lower-case, _-separated that my current code generates. Not
a technical reason, more of an aesthetic one.

Thanks for the suggestion.

Bye,
-- 
Pedro Melo
http://www.simplicidade.org/
xmpp:m...@simplicidade.org
mailto:m...@simplicidade.org

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk

Reply via email to