Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Previous section Next section Previous page Next page Up level
What's New
11/18/09 - A major update brings our collection to over 1,350 manuals for 115 brands.
11/04/09 - New features, hundreds of 2-way and RS-232 modules, plus a web browser for the MX-6000.
9/04/09 - Latest activity-based model features a color screen at an economical price.
9/03/09 - * OK, one string – you may have to learn something!
8/22/09 - As it turns out, those who do not learn from history... still won't repeat it.

Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Page 3 of 3
Topic:
Optimize your Prontoscript!!!
This thread has 32 replies. Displaying posts 31 through 33.
Post 31 made on Friday November 6, 2009 at 15:23
Rusty Fobe
Junior Member
Joined:
Posts:
December 2008
42
Ok, thanks Mike, so you can come a bit closer to "compiled code" by using Regexp, but as far as I understand only for text interpretations.
Post 32 made on Friday November 6, 2009 at 23:23
mraneri
Regular Member
Joined:
Posts:
February 2009
113
Yeah... The interpreted javascript for loop iterates once for each instance of a two+ byte character sequence. So, if you have a 1000 byte string, with 10 special characters, the for loop iterates 10 times. The regexp does the gruntwork of FINDING the two byte sequences.

I suspect you would find compiled methods will run much faster than interpreted methods, whenever compiled methods are available... For instance, if you wanted to find the location of one string within another, you could write a javascript for loop, iterating through each character in the string and doing a compare. You would use String.indexOf(). I suspect indexOf() is implemented in compiled machine code, and would run orders of magnitude faster than the most optimized for loop you could write in native javascript.

This is a "duh" example. The thought of using a Regexp to find UTF8 sequences is not as obvious...

You just have to think out of the box... "How might I accomplish this using Built-In functions???" You also have to know the built-in functions... For instance, if you didn't know you could execute a regexp search on a string, how could you know you could optimize a UTF8 decoder with it???

You have to read all the methods for all your objects, and figure out which ones might help you someday... BTW, Regexp is a potentially very powerful tool... But then, you have to learn the Regexp "language" itself to fully utilize it...

I know some of this stuff is obvious to some who've been programming for years... But it may not be obvious to all.

Hope it helps some.

- Mike
Post 33 made on Saturday November 7, 2009 at 06:46
Rusty Fobe
Junior Member
Joined:
Posts:
December 2008
42
Ok Mike, I understand now after analyzing your code. I replaced my code now and it works great with the correction included (and very fast indeed).

Actually, there are still some issues, but that's not due to your code. The rss pages do miss charset and/or language though. The sources (from the two newspapers) looked different on my PC for the same news message.

Italië page contained nl-BE, but no charset
Italië page contained charset=UTF-8, but no language

So after using the UTF8 function, the remainder literally contains "&words", which I solved (reluctantly, because there will be more exceptions I guess) by the code below. Does anyone know a solution? Would the addition of language or charset solve the issue?

Thanks in advance, Rusty

s=UTF8(s);

// still & remaining in the output
if (s.indexOf('&')>0){
s=s.replace(/á/g,'á');
s=s.replace(/à/g,'à');
s=s.replace(/ç/g,'ç');
s=s.replace(/ï/g,'ï');
s=s.replace(/ë/g,'ë');
s=s.replace(/é/g,'é');
s=s.replace(/è/g,'è');
s=s.replace(/ê/g,'ê');
s=s.replace(/ó/g,'ó');
s=s.replace(/ü/g,'ü');}

Last edited by Rusty Fobe on November 7, 2009 15:58.
Page 3 of 3


Jump to


Protected Feature Before you can reply to a message...
You must first register for a Remote Central user account - it's fast and free! Or, if you already have an account, please login now.

Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our Marketplace. For information on how to advertise your service or product click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.

Hosting Services by ipHouse