Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6b41a15

Browse files
committed
Simplify coding style of is_valid_ascii()
Calculate end of input rather than maintaining length,per prior suggestion from Heikki Linnakangas. In passing,use more natural language in a comment.Discussion:https://www.postgresql.org/message-id/b4648cc2-5e9c-c93a-52cc-51e5c658a4f6%40iki.fi
1 parent82593b9 commit6b41a15

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

‎src/include/mb/pg_wchar.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -709,13 +709,14 @@ extern WCHAR *pgwin32_message_to_UTF16(const char *str, int len, int *utf16len);
709709
staticinlinebool
710710
is_valid_ascii(constunsignedchar*s,intlen)
711711
{
712+
constunsignedchar*consts_end=s+len;
712713
uint64chunk,
713714
highbit_cum=UINT64CONST(0),
714715
zero_cum=UINT64CONST(0x8080808080808080);
715716

716717
Assert(len %sizeof(chunk)==0);
717718

718-
while (len>0)
719+
while (s<s_end)
719720
{
720721
memcpy(&chunk,s,sizeof(chunk));
721722

@@ -734,11 +735,10 @@ is_valid_ascii(const unsigned char *s, int len)
734735
*/
735736
zero_cum &= (chunk+UINT64CONST(0x7f7f7f7f7f7f7f7f));
736737

737-
/* Captureany set bits in this chunk. */
738+
/* Captureall set bits in this chunk. */
738739
highbit_cum |=chunk;
739740

740741
s+=sizeof(chunk);
741-
len-=sizeof(chunk);
742742
}
743743

744744
/* Check if any high bits in the high bit accumulator got set. */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp