Skip to content

Commit fdde77f

Browse files
anaxarsysAnatolii Sakhnik
authored andcommitted
Improve performance in json stream parsing
:Release Notes: Add yajl_dont_validate_strings for Yajl 2. Custom simple memory pool. Throughput measurement in MBps. Add pool of dom parsers. :Detailed Notes: Add yajl_dont_validate_strings for Yajl 2. Memory pool gives us a big win in performance. Fix performance tests to measure the throughput in MB/s. Some small improvements and code refactoring. :Testing Performed: gtest :QA Notes: :Issues Addressed: [BHV-123] pbnjson: Improve performance of json parsing with YAJL Open-webOS-DCO-1.0-Signed-off-by: Andrii Zora <[email protected]> Change-Id: Ic2b49103cf438c77e48f961258e9842fd84fb7d0 Reviewed-on: https://g2g.palm.com/4631 Reviewed-by: DCO Verification Reviewed-by: Andrii Zora <[email protected]> Tested-by: Andrii Zora <[email protected]> Reviewed-by: Anatolii Sakhnik <[email protected]> Tested-by: Anatolii Sakhnik <[email protected]>
1 parent 6b138cb commit fdde77f

File tree

9 files changed

+372
-158
lines changed

9 files changed

+372
-158
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ webos_component(2 5 0)
2626
include(FindPkgConfig)
2727

2828
find_library(GMP_LIBRARY gmp ${LIB_INSTALL_DIR})
29+
find_package(Threads)
2930

3031
pkg_check_modules(GLIB2 REQUIRED glib-2.0)
3132
include_directories(${GLIB2_INCLUDE_DIRS})
32-
webos_add_compiler_flags(ALL -Wall -D__STRICT_ANSI__ ${GLIB2_CFLAGS_OTHER})
33+
webos_add_compiler_flags(ALL -Wall -D__STRICT_ANSI__ ${GLIB2_CFLAGS_OTHER} -pthread)
3334

3435
# YAJL-1 doesn't ship any pkg-check module
3536
pkg_check_modules(YAJL yajl)

src/pbnjson_c/CMakeLists.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# @@@LICENSE
22
#
3-
# Copyright (c) 2009-2013 LG Electronics, Inc.
3+
# Copyright (c) 2009-2014 LG Electronics, Inc.
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -71,7 +71,14 @@ add_library(
7171
jschema.c
7272
jvalidation.c
7373
)
74-
target_link_libraries(pbnjson_c jvalue schema_validation ${GLIB2_LDFLAGS} ${YAJL_LDFLAGS})
74+
target_link_libraries(
75+
pbnjson_c
76+
jvalue
77+
schema_validation
78+
${GLIB2_LDFLAGS}
79+
${YAJL_LDFLAGS}
80+
${CMAKE_THREAD_LIBS_INIT}
81+
)
7582
set_target_properties(pbnjson_c PROPERTIES DEFINE_SYMBOL PJSON_SHARED)
7683

7784
include_directories(

src/pbnjson_c/jobject.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,15 +1228,16 @@ bool jarray_has_duplicates(jvalue_ref arr)
12281228
assert(jis_array(arr));
12291229

12301230
ssize_t size = jarray_size(arr);
1231-
if (size < 2)
1232-
return false;
12331231

12341232
for (ssize_t i = 0; i < size - 1; ++i)
1233+
{
1234+
jvalue_ref jvali = *jarray_get_unsafe(arr, i);
12351235
for (ssize_t j = i + 1; j < size; ++j)
12361236
{
1237-
if (jvalue_equal(*jarray_get_unsafe(arr, i), *jarray_get_unsafe(arr, j)))
1237+
if (jvalue_equal(jvali, *jarray_get_unsafe(arr, j)))
12381238
return true;
12391239
}
1240+
}
12401241

12411242
return false;
12421243
}

0 commit comments

Comments
 (0)