diff options
author | Özgür Kesim <oec-taler@kesim.org> | 2023-05-14 19:19:34 +0200 |
---|---|---|
committer | Özgür Kesim <oec-taler@kesim.org> | 2023-05-14 19:19:34 +0200 |
commit | cb7d9ba50f7f126357f2755cc76ce380bd8aa0f4 (patch) | |
tree | 4cbeb7f75382bb9d004d9653819fa778f80f2ca6 | |
parent | 862cb846625d0b1bae530f82f524388a677b883c (diff) | |
download | gnunet-cb7d9ba50f7f126357f2755cc76ce380bd8aa0f4.tar.gz gnunet-cb7d9ba50f7f126357f2755cc76ce380bd8aa0f4.zip |
-pq: slight optimization
-rw-r--r-- | src/pq/pq_query_helper.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/pq/pq_query_helper.c b/src/pq/pq_query_helper.c index 1f13270c3..1a31333d9 100644 --- a/src/pq/pq_query_helper.c +++ b/src/pq/pq_query_helper.c | |||
@@ -782,6 +782,7 @@ qconv_array ( | |||
782 | { | 782 | { |
783 | char *in = (char *) data; | 783 | char *in = (char *) data; |
784 | char *out = elements; | 784 | char *out = elements; |
785 | size_t nullbyte = (array_of_string == meta->typ) ? 1 : 0; | ||
785 | struct pq_array_header h = { | 786 | struct pq_array_header h = { |
786 | .ndim = htonl (1), /* We only support one-dimensional arrays */ | 787 | .ndim = htonl (1), /* We only support one-dimensional arrays */ |
787 | .has_null = htonl (0), /* We do not support NULL entries in arrays */ | 788 | .has_null = htonl (0), /* We do not support NULL entries in arrays */ |
@@ -794,6 +795,7 @@ qconv_array ( | |||
794 | GNUNET_memcpy (out, &h, sizeof(h)); | 795 | GNUNET_memcpy (out, &h, sizeof(h)); |
795 | out += sizeof(h); | 796 | out += sizeof(h); |
796 | 797 | ||
798 | |||
797 | /* Write elements */ | 799 | /* Write elements */ |
798 | for (unsigned int i = 0; i < num; i++) | 800 | for (unsigned int i = 0; i < num; i++) |
799 | { | 801 | { |
@@ -840,9 +842,7 @@ qconv_array ( | |||
840 | if (meta->continuous) | 842 | if (meta->continuous) |
841 | { | 843 | { |
842 | ptr = in; | 844 | ptr = in; |
843 | in += sz; | 845 | in += sz + nullbyte; |
844 | if (array_of_string == meta->typ) | ||
845 | in += 1; /* NULL-byte */ | ||
846 | } | 846 | } |
847 | else | 847 | else |
848 | ptr = ((const void **) data)[i]; | 848 | ptr = ((const void **) data)[i]; |
@@ -933,7 +933,7 @@ qconv_array ( | |||
933 | param_formats[0] = 1; | 933 | param_formats[0] = 1; |
934 | scratch[0] = elements; | 934 | scratch[0] = elements; |
935 | 935 | ||
936 | DONE: | 936 | DONE: |
937 | GNUNET_free (string_lengths); | 937 | GNUNET_free (string_lengths); |
938 | 938 | ||
939 | if (noerror) | 939 | if (noerror) |