Gamestudio Links
Zorro Links
Newest Posts
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
LPDIRECT3DCUBETEXTUR
E9

by Ayumi. 04/12/24 11:00
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 04/11/24 14:56
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Quad), 509 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
11honza11, ccorrea, sakolin, rajesh7827, juergen_wue
19045 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
str_stri surcharge #449033
02/28/15 11:53
02/28/15 11:53
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline OP
Serious User
txesmi  Offline OP
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
Hi,
I needed to intensively use str_stri for a osm hypertext parser I am writing and I realized that it got slower the bigger the parsed strings or char buffers were. In the try of indetifying the problem I substituted all the str_stri calls by my own function and surprisingly it solved the problem. I could not believe it.

Click to reveal..

Code:
var str_stri_custom ( char *chr1, char *chr2 )
{
	var pos = 0;
	while ( *chr1 != NULL )
	{
		pos += 1;
		if ( *chr1 == *chr2 )
		{
			char *chr1b = chr1 + 1;
			char *chr2b = chr2 + 1;
			while ( ( *chr1b != NULL ) && ( *chr2b != NULL ) )
			{
				if ( *chr1b != *chr2b )
					break;
				chr1b += 1;
				chr2b += 1;
			}
			if ( *chr2b == NULL )
				return pos;
		}
		chr1 += 1;
	}
	return 0;
}



Re: str_stri surcharge [Re: txesmi] #449047
03/02/15 11:01
03/02/15 11:01
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
Did you also try in published mode?

I don't know the engine code - but for sure there's a certain chance that in development mode there are debug routines active for detecting array out of bounds and the like.

Re: str_stri surcharge [Re: FBL] #449050
03/02/15 14:39
03/02/15 14:39
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
There is some overhead in development mode, but it should not make much difference. str_stri is in fact very slow, as far as I can see in the source code. Your function is much faster. I don't see at a first glance why str_stri is coded this way, maybe it's due to some special case handling. As long as you don't use unicode or some STRING specific stuff I recommend that you continue with your own function.

Re: str_stri surcharge [Re: jcl] #449078
03/03/15 12:28
03/03/15 12:28
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline OP
Serious User
txesmi  Offline OP
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
Thank you for your answers!
I will go this way. Maybe a chr_cmp is a good choice too.

Salud!


Moderated by  jcl, Nems, Spirit, Tobias 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1