[Gambas-user] Gambas is slower than Python??

birchy pokerbirch at ...1601...
Sun Jan 18 22:36:12 CET 2009


Well i've just managed to find my ORIGINAL (VB6) code and did a direct port
to Gambas. My previous example using Split() was the way that seemed most
logical when i decide to quickly write the function in Gambas:
[quote author="CODE"]
PRIVATE FUNCTION GetSubstring(mainstring AS String, startstring AS String,
endstring AS String) AS String 
    DIM pos AS Long 
     
    IF mainstring AND startstring AND endstring THEN 
        pos = InStr(mainstring, startstring) 
        IF pos THEN 
            mainstring = Right$(mainstring, Len(mainstring) - pos -
Len(startstring) + 1) 
            pos = InStr(mainstring, endstring) 
            IF pos THEN RETURN Left$(mainstring, pos - 1) 
        END IF 
    END IF 
END FUNCTION

Note that the above code includes sanity checks to ensure that the
'endstring' is the first occurrence AFTER 'startstring'. Minus the sanity
check:
[quote author="CODE"]
PRIVATE FUNCTION GetSubstring5(mainstring AS String, startstring AS String,
endstring AS String) AS String
  DIM pos AS Integer, length AS Integer

  pos = InStr(mainstring, startstring) + Len(startstring)
  length = Len(mainstring) - InStr(mainstring, endstring) + Len(endstring)
  RETURN Mid$(mainstring, pos, length)
END 


-- 
View this message in context: http://www.nabble.com/Gambas-is-slower-than-Python---tp21521606p21533340.html
Sent from the gambas-user mailing list archive at Nabble.com.





More information about the User mailing list