Modify to use phone_number_connect() for performance 35/167235/1 accepted/tizen/unified/20180117.060721 submit/tizen/20180116.095454
authorJongkyu Koo <jk.koo@samsung.com>
Tue, 16 Jan 2018 05:48:28 +0000 (14:48 +0900)
committerJongkyu Koo <jk.koo@samsung.com>
Tue, 16 Jan 2018 09:34:10 +0000 (09:34 +0000)
Change-Id: I990ebe18da3250102d7a404c949843db5c422141
Signed-off-by: Jongkyu Koo <jk.koo@samsung.com>
server/ctsvc_ipc_server.c
server/db/ctsvc_db_query.c

index e57afc8..c2536a3 100644 (file)
@@ -1243,6 +1243,7 @@ void ctsvc_ipc_server_db_insert_records(pims_ipc_h ipc, pims_ipc_data_h indata,
                contacts_list_first(list);
        }
 
+       ctsvc_server_stop_timeout();
        ret = ctsvc_db_insert_records(list, &ids, &id_count);
 
        if (outdata) {
@@ -1387,6 +1388,7 @@ void ctsvc_ipc_server_db_update_records(pims_ipc_h ipc, pims_ipc_data_h indata,
                contacts_list_first(list);
        }
 
+       ctsvc_server_stop_timeout();
        ret = ctsvc_db_update_records(list);
 
        if (outdata) {
@@ -1668,6 +1670,7 @@ void ctsvc_ipc_server_db_replace_records(pims_ipc_h ipc, pims_ipc_data_h indata,
                contacts_list_first(list);
        }
 
+       ctsvc_server_stop_timeout();
        ret = ctsvc_db_replace_records(list, ids, count);
 
        if (outdata) {
index 64960a9..ff3efce 100644 (file)
@@ -17,6 +17,7 @@
  *
  */
 #include <glib.h>
+#include <phone_number.h>
 
 #include "contacts.h"
 #include "contacts_internal.h"
@@ -3728,6 +3729,8 @@ static int __ctsvc_db_insert_records(contacts_list_h list, int **ids)
 
        contacts_list_first(list);
        index = 0;
+       /* for performance. phone_number_get_normalized_number() can be called repeatedly below */
+       phone_number_connect();
        do {
                ret = contacts_list_get_current_record_p(list, &record);
                if (CONTACTS_ERROR_NONE != ret) {
@@ -3735,6 +3738,7 @@ static int __ctsvc_db_insert_records(contacts_list_h list, int **ids)
                        ERR("contacts_list_get_current_record_p() Fail(%d)", ret);
                        ctsvc_end_trans(false);
                        free(id);
+                       phone_number_disconnect();
                        return ret;
                        /* LCOV_EXCL_STOP */
                }
@@ -3745,11 +3749,12 @@ static int __ctsvc_db_insert_records(contacts_list_h list, int **ids)
                        ERR("contacts_db_insert_record() Fail(%d)", ret);
                        ctsvc_end_trans(false);
                        free(id);
+                       phone_number_disconnect();
                        return ret;
                        /* LCOV_EXCL_STOP */
                }
        } while (CONTACTS_ERROR_NONE  == contacts_list_next(list));
-
+       phone_number_disconnect();
        ret = ctsvc_end_trans(true);
        if (ret < CONTACTS_ERROR_NONE) {
                /* LCOV_EXCL_START */
@@ -3814,12 +3819,15 @@ static int __ctsvc_db_update_records(contacts_list_h list)
        RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_begin_trans() Fail(%d)", ret);
 
        contacts_list_first(list);
+       /* for performance. phone_number_get_normalized_number() can be called repeatedly below */
+       phone_number_connect();
        do {
                ret = contacts_list_get_current_record_p(list, &record);
                if (CONTACTS_ERROR_NONE != ret) {
                        /* LCOV_EXCL_START */
                        ERR("contacts_list_get_current_record_p() Fail(%d)", ret);
                        ctsvc_end_trans(false);
+                       phone_number_disconnect();
                        return ret;
                        /* LCOV_EXCL_STOP */
                }
@@ -3829,10 +3837,12 @@ static int __ctsvc_db_update_records(contacts_list_h list)
                        /* LCOV_EXCL_START */
                        ERR("contacts_db_update_record() Fail(%d)", ret);
                        ctsvc_end_trans(false);
+                       phone_number_disconnect();
                        return ret;
                        /* LCOV_EXCL_STOP */
                }
        } while (CONTACTS_ERROR_NONE == contacts_list_next(list));
+       phone_number_disconnect();
        ret = ctsvc_end_trans(true);
        if (ret < CONTACTS_ERROR_NONE) {
                /* LCOV_EXCL_START */
@@ -4789,12 +4799,15 @@ static int __ctsvc_db_replace_records(contacts_list_h list, int ids[], int count
 
        contacts_list_first(list);
        i = 0;
+       /* for performance. phone_number_get_normalized_number() can be called repeatedly below */
+       phone_number_connect();
        do {
                ret = contacts_list_get_current_record_p(list, &record);
                if (CONTACTS_ERROR_NONE != ret) {
                        /* LCOV_EXCL_START */
                        ERR("contacts_list_get_current_record_p() Fail(%d)", ret);
                        ctsvc_end_trans(false);
+                       phone_number_disconnect();
                        return ret;
                        /* LCOV_EXCL_STOP */
                }
@@ -4804,11 +4817,12 @@ static int __ctsvc_db_replace_records(contacts_list_h list, int ids[], int count
                        /* LCOV_EXCL_START */
                        ERR("contacts_db_replace_record() Fail(%d)", ret);
                        ctsvc_end_trans(false);
+                       phone_number_disconnect();
                        return ret;
                        /* LCOV_EXCL_STOP */
                }
        } while (CONTACTS_ERROR_NONE == contacts_list_next(list));
-
+       phone_number_disconnect();
        ret = ctsvc_end_trans(true);
 
        return ret;