Re: question on func equal_from

new topic     » goto parent     » topic index » view thread      » older message » newer message

> The typical use cases for the *from()s were parsing some sort of string.
> Perhaps replacing all occurrences of a certain set of characters, or 
> tokenizing based on a comma or a tab.  There were many repetitive uses 
> of the function, and it gave a significant speed up.  Is there a 
> similar use case for equal_from()?
> 

I think there is. I regularly use similar repetitive uses of the equal 
function to find (many) keywords in long texts.

But my message is rather just a question that helps me to understand 
how to argue and support a new feature to be implemented in the next 
official relase... 

(Although secretly I hoped some positive replies. blink)

Best regards,

Salix

P.S.: Actually my match_from bug report is linked to the very same 
example. Instead of 

constant tx="very long sequence"

for i=1 to length(tx) by 1 do
	if i>7 and equal("https://",tx[i-7..i]) then
		-- do something
	elsif i>6 and equal("http://",tx[i-7..i]) then
		-- do something
	elsif i>5 and equal("ftp://",tx[i-7..i]) then
		-- do something
	end if
end for


I would use 

for i=1 to length(tx) by 1 do
	if match_from("https://",tx[1..i],i-7) then
		-- do something
	elsif match_from("http://",tx[1..i],i-6) then
		-- do something
	elsif match_from("ftp://",tx[1..i],i-5) then
		-- do something
	end if
end for


because it is nicer, although slower. (But with equal_from 
it could be equally fast but even nicer!) :-]

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu