[Groonga-commit] groonga/groonga at 4dd4b58 [master] mrb: reduce double strlen()

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Jun 18 17:20:11 JST 2018


Kouhei Sutou	2018-06-18 17:20:11 +0900 (Mon, 18 Jun 2018)

  New Revision: 4dd4b588555a1e421eaeaedaa35b647704e62ce5
  https://github.com/groonga/groonga/commit/4dd4b588555a1e421eaeaedaa35b647704e62ce5

  Message:
    mrb: reduce double strlen()

  Modified files:
    lib/mrb.c

  Modified: lib/mrb.c (+4 -2)
===================================================================
--- lib/mrb.c    2018-06-18 17:04:34 +0900 (fbcfcaf96)
+++ lib/mrb.c    2018-06-18 17:20:11 +0900 (df04bf5d8)
@@ -71,20 +71,22 @@ grn_mrb_is_order_by_estimated_size_enabled(void)
 static char *
 grn_mrb_string_locale_to_utf8(grn_ctx *ctx, const char *locale_string)
 {
+  size_t locale_string_bytes;
   wchar_t *wide_string;
   int n_wide_chars;
   char *utf8_string;
   int utf8_string_bytes;
 
+  locale_string_bytes = strlen(locale_string);
   n_wide_chars = MultiByteToWideChar(CP_ACP, 0,
-                                     locale_string, -1,
+                                     locale_string, locale_string_bytes,
                                      NULL, 0);
   wide_string = GRN_MALLOCN(wchar_t, n_wide_chars);
   if (!wide_string) {
     return NULL;
   }
   n_wide_chars = MultiByteToWideChar(CP_ACP, 0,
-                                     locale_string, locale_string_length,
+                                     locale_string, locale_string_bytes,
                                      wide_string, n_wide_chars);
   utf8_string_bytes = WideCharToMultiByte(CP_UTF8, 0,
                                           wide_string, n_wide_chars,
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180618/672a4399/attachment-0001.htm 



More information about the Groonga-commit mailing list
Back to archive index