Hello everyone,

Some time ago I had created a string handling library
for my vb projects, which would speed up string
concatenations. When I started programming in
javascript I've realized that there was a need for
such a library since javascript had the same problem
as VB.

StringObject is a very simple javascript object that
can in cases where you might need to do string
concatenations:

        StringObject=function(){}
        StringObject.prototype.db=[];
        StringObject.prototype.add=function(src){
                this.db[this.db.length]=src;
        }
        StringObject.prototype.toString=function(delim){
                return this.db.join(delim||'');
        }
        StringObject.prototype.flush=function(){
                this.db=[];
        }
        StringObject.prototype.indexOf=function(q){
                return this.db.join('').indexOf(q)
        }


Here's an example:


// #1: Conventional method
        var src='',din=new Date()
        for (var i=0;i<2000;i++){
                d=" svcsvadvnvdv gdg rgr gr gr grgrg <br>"
                src+=d 
        }
        //src=src.indexOf("1999") // simple lookup
        var dout=new Date()
        alert(dout-din)



// #2: With StringObject
        var src='',din=new Date()
        so=new StringObject()

        for (var i=0;i<2000;i++){
                d=" svcsvadvnvdv gdg rgr gr gr grgrg <br>"
                so.add(d)
        }
        src=so.toString('')
        //src=so.indexOf("1999") // simple lookup
        var dout=new Date()
        alert(dout-din)


The above example (#2) when tested on a pentium 200MHz
was able to process over 70,000 characters in under
0.03 seconds! Try doing that using the conventional
methods.

I would like to proposed that such an object be added
to DynAPI core so that users don't have to implement
separate objects for their widgets or extensions. They
could just reference it from the core.



--
Raymond


__________________________________________________
Do You Yahoo!?
Find a job, post your resume.
http://careers.yahoo.com

_______________________________________________
Dynapi-Help mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dynapi-help

Reply via email to