Please nominate your Qt Champions for 2021!

[SOLVED] can QString::contains() be fast?

  • I am looking for a keyword in a long string by using the contains() function. The keyword is at the beginning (not exactly but close). Will it be as fast or almost as fast as if I was searching in a small string?

    ex: "1 or 2 words I AM LOOKING FOR THIS more words maybe 200 or so"

  • According to the implementation:

    bq. We use the Boyer-Moore algorithm in cases where the overhead for the skip table should pay off, otherwise we use a simple hash function.

    The Boyer-Moore algorithm is used if string length is greater than 500 and the search string length is greater than 5.

  • thanks! That's what I needed to know.

Log in to reply