[PATCH] Loop refactoring
Jean-Marc Lasgouttes
lasgouttes at lyx.org
Thu Oct 8 13:28:19 UTC 2020
Le 07/10/2020 à 17:31, Richard Kimberly Heck a écrit :
> On 10/7/20 10:31 AM, Yuriy Skalko wrote:
>> And the last patch based on the static analyzers output.
>
> diff --git a/src/Author.cpp b/src/Author.cpp
> index 9a2dc1ea43..b4cf9fd97b 100644
> --- a/src/Author.cpp
> +++ b/src/Author.cpp
> @@ -31,8 +31,8 @@ static int computeHash(docstring const & name,
> string const full_author_string = to_utf8(name + email);
> // Bernstein's hash function
> unsigned int hash = 5381;
> - for (unsigned int i = 0; i < full_author_string.length(); ++i)
> - hash = ((hash << 5) + hash) + (unsigned int)(full_author_string[i]);
> + for (char c : full_author_string)
>
> It shouldn't matter much here, but this can presumably be const &.
> There are other cases where it does matter, though, and I think
> we will see other warnings about this. So I'd fix them all while
> we're at it. I won't mark the other char and char_type ones.
I do not think we should do that for POD : instead of passing a 32bit
number (here even small, but it does not matter that much), one passes a
64bit pointer that can be used to get a 32 bit number.
JMarc
More information about the lyx-devel
mailing list