On Dec 10, 6:54 am, Robert Koberg <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Is there a particular style of writing javascript objects that rhino  
> performs best with? For example, I would prefer to write JS like the  
> first script example below. Does it matter how you write the JS?
>
> For example:
>
> (function() {
>   var privateFunc = function(request, response) {
> ...
>   }
>   return {
>     GET: function(params) {
>       var request = params.request;
>       var response = params. response;
>       privateFunc(request, response);
> ...
>     }
>   }
>
> })();
>
> or should you write your functions like:
>
> function GET() {
>
> }
>
> or
>
> var GET = function() {
>
> }
>
> or
>
> var Obj = {
>   GET: function() {
>
>   }
>
> }
>
> etc...

I don't think Rhino should perform any differently between these
various styles. Functions that *contain* closures will perform more
slowly than functions that don't contain closures since they must
create an activation object for locals so that the closure has access
to the locals, but the performance of a function that is used as a
closure should be the same as a top-level function.

--N
--N
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to