Skip to content

Commit 9bb55e2

Browse files
committed
Remove the array initialization for performance optimization.
1 parent b0ad14a commit 9bb55e2

30 files changed

+51
-46
lines changed

cstl/cstl_basic_string.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The interface of basic_string.
3-
* Copyright (C) 2008 - 2012 Wangbo
3+
* Copyright (C) 2008 - 2014 Wangbo
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

cstl/cstl_basic_string_private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The private interface of basic_string.
3-
* Copyright (C) 2008 - 2013 Wangbo
3+
* Copyright (C) 2008 - 2014 Wangbo
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

cstl/cstl_deque_iterator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The deque iterator interface for iterator module.
3-
* Copyright (C) 2008 - 2012 Wangbo
3+
* Copyright (C) 2008 - 2014 Wangbo
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

cstl/cstl_hash_map.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The interface of hash_map.
3-
* Copyright (C) 2008 - 2013 Wangbo
3+
* Copyright (C) 2008 - 2014 Wangbo
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

cstl/cstl_hash_set_iterator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The iterator interface of hash_set.
3-
* Copyright (C) 2008 - 2012 Wangbo
3+
* Copyright (C) 2008 - 2014 Wangbo
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

cstl/cstl_hashtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The interface of hashtable.
3-
* Copyright (C) 2008 - 2013 Wangbo
3+
* Copyright (C) 2008 - 2014 Wangbo
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

cstl/cstl_list_iterator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The list iterator interface for iterator module.
3-
* Copyright (C) 2008 - 2012 Wangbo
3+
* Copyright (C) 2008 - 2014 Wangbo
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

cstl/cstl_list_private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The definition of list_t struct.
3-
* Copyright (C) 2008 - 2012 Wangbo
3+
* Copyright (C) 2008 - 2014 Wangbo
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

cstl/cstl_map.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The interface of map.
3-
* Copyright (C) 2008 - 2013 Wangbo
3+
* Copyright (C) 2008 - 2014 Wangbo
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

cstl/cstl_rb_tree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The interface of rb tree.
3-
* Copyright (C) 2008 - 2013 Wangbo
3+
* Copyright (C) 2008 - 2014 Wangbo
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

src/cstl_algo_mutating_aux.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The interface of auxiliary mutating algorithm.
3-
* Copyright (C) 2008 - 2013 Wangbo
3+
* Copyright (C) 2008 - 2014 Wangbo
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

src/cstl_avl_tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The implementation of avl tree.
3-
* Copyright (C) 2008 - 2013 Wangbo
3+
* Copyright (C) 2008 - 2014 Wangbo
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

src/cstl_avl_tree_iterator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The implementation of avl tree iterator interface.
3-
* Copyright (C) 2008 - 2012 Wangbo
3+
* Copyright (C) 2008 - 2014 Wangbo
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

src/cstl_deque.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The implement of deque module.
3-
* Copyright (C) 2008 - 2012 Wangbo
3+
* Copyright (C) 2008 - 2014 Wangbo
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

src/cstl_deque_private.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The implement of deque private function.
3-
* Copyright (C) 2008 - 2012 Wangbo
3+
* Copyright (C) 2008 - 2014 Wangbo
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

src/cstl_hashtable.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The implementation of hashtable.
3-
* Copyright (C) 2008 - 2013 Wangbo
3+
* Copyright (C) 2008 - 2014 Wangbo
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

src/cstl_hashtable_aux.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The implementation of hashtable auxiliary functions.
3-
* Copyright (C) 2008 - 2012 Wangbo
3+
* Copyright (C) 2008 - 2014 Wangbo
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

src/cstl_hashtable_iterator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The implementation of hashtable iterator.
3-
* Copyright (C) 2008 - 2012 Wangbo
3+
* Copyright (C) 2008 - 2014 Wangbo
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

src/cstl_list.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The implement of list module.
3-
* Copyright (C) 2008 - 2013 Wangbo
3+
* Copyright (C) 2008 - 2014 Wangbo
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

src/cstl_list_private.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The implement of list private interface.
3-
* Copyright (C) 2008 - 2012 Wangbo
3+
* Copyright (C) 2008 - 2014 Wangbo
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

src/cstl_rb_tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The implementation of rb tree.
3-
* Copyright (C) 2008 - 2013 Wangbo
3+
* Copyright (C) 2008 - 2014 Wangbo
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

src/cstl_rb_tree_iterator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The implementation of rb tree iterator.
3-
* Copyright (C) 2008 - 2012 Wangbo
3+
* Copyright (C) 2008 - 2014 Wangbo
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

src/cstl_set.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The implementation of set.
3-
* Copyright (C) 2008 - 2013 Wangbo
3+
* Copyright (C) 2008 - 2014 Wangbo
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

src/cstl_slist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The implementation of slist.
3-
* Copyright (C) 2008 - 2013 Wangbo
3+
* Copyright (C) 2008 - 2014 Wangbo
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

src/cstl_slist_private.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The implementation of slist private function.
3-
* Copyright (C) 2008 - 2012 Wangbo
3+
* Copyright (C) 2008 - 2014 Wangbo
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

src/cstl_types.c

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ bool_t _type_register(
9999
ufun_t t_typeinit, bfun_t t_typecopy,
100100
bfun_t t_typeless, ufun_t t_typedestroy)
101101
{
102-
char s_formalname[_TYPE_NAME_SIZE + 1] = {'\0'};
102+
char s_formalname[_TYPE_NAME_SIZE + 1];
103103
_typestyle_t t_style = _TYPE_INVALID;
104104

105105
if (!_gt_typeregister._t_isinit) {
@@ -143,8 +143,8 @@ bool_t _type_duplicate(
143143
{
144144
_type_t* pt_registered1 = NULL;
145145
_type_t* pt_registered2 = false;
146-
char s_formalname1[_TYPE_NAME_SIZE + 1] = {'\0'};
147-
char s_formalname2[_TYPE_NAME_SIZE + 1] = {'\0'};
146+
char s_formalname1[_TYPE_NAME_SIZE + 1];
147+
char s_formalname2[_TYPE_NAME_SIZE + 1];
148148

149149
assert(s_typename1 != NULL);
150150
assert(s_typename2 != NULL);
@@ -206,8 +206,8 @@ bool_t _type_duplicate(
206206
void _type_get_type_pair(_typeinfo_t* pt_typeinfofirst, _typeinfo_t* pt_typeinfosecond, const char* s_typename)
207207
{
208208
/* this function get type information for pair_t and relation container */
209-
char s_firsttypename[_TYPE_NAME_SIZE + 1] = {'\0'};
210-
char s_secondtypename[_TYPE_NAME_SIZE + 1] = {'\0'};
209+
char s_firsttypename[_TYPE_NAME_SIZE + 1];
210+
char s_secondtypename[_TYPE_NAME_SIZE + 1];
211211
char* pc_commapos = NULL;
212212
char* pc_newstart = NULL;
213213

@@ -223,9 +223,10 @@ void _type_get_type_pair(_typeinfo_t* pt_typeinfofirst, _typeinfo_t* pt_typeinfo
223223
/* the type name is separated in two section by comma */
224224
pc_newstart = (char*)s_typename;
225225
while ((pc_commapos = strchr(pc_newstart, _CSTL_COMMA)) != NULL) {
226-
memset(s_firsttypename, '\0', _TYPE_NAME_SIZE + 1);
227-
memset(s_secondtypename, '\0', _TYPE_NAME_SIZE + 1);
226+
s_firsttypename[0] = s_firsttypename[_TYPE_NAME_SIZE] = '\0';
227+
s_secondtypename[0] = s_secondtypename[_TYPE_NAME_SIZE] = '\0';
228228
strncpy(s_firsttypename, s_typename, pc_commapos - s_typename);
229+
s_firsttypename[pc_commapos - s_typename] = '\0';
229230
strncpy(s_secondtypename, pc_commapos + 1, _TYPE_NAME_SIZE);
230231

231232
_type_get_type(pt_typeinfofirst, s_firsttypename);
@@ -377,10 +378,10 @@ void _type_get_type(_typeinfo_t* pt_typeinfo, const char* s_typename)
377378
bool_t _type_is_same(const char* s_typename1, const char* s_typename2)
378379
{
379380
/* s_typename1 and s_typename2 is formal name */
380-
char s_elemname1[_TYPE_NAME_SIZE + 1] = {'\0'};
381-
char s_prefix1[_TYPE_NAME_SIZE + 1] = {'\0'};
382-
char s_elemname2[_TYPE_NAME_SIZE + 1] = {'\0'};
383-
char s_prefix2[_TYPE_NAME_SIZE + 1] = {'\0'};
381+
char s_elemname1[_TYPE_NAME_SIZE + 1];
382+
char s_prefix1[_TYPE_NAME_SIZE + 1];
383+
char s_elemname2[_TYPE_NAME_SIZE + 1];
384+
char s_prefix2[_TYPE_NAME_SIZE + 1];
384385
char* pc_index1 = NULL;
385386
char* pc_leftbracket1 = NULL;
386387
char* pc_rightbracket1 = NULL;
@@ -393,6 +394,8 @@ bool_t _type_is_same(const char* s_typename1, const char* s_typename2)
393394
assert(s_typename1 != NULL);
394395
assert(s_typename2 != NULL);
395396

397+
s_elemname1[0] = s_elemname1[_TYPE_NAME_SIZE] = '\0';
398+
s_elemname2[0] = s_elemname2[_TYPE_NAME_SIZE] = '\0';
396399
strncpy(s_elemname1, s_typename1, _TYPE_NAME_SIZE);
397400
strncpy(s_elemname2, s_typename2, _TYPE_NAME_SIZE);
398401

@@ -459,21 +462,23 @@ bool_t _type_is_same(const char* s_typename1, const char* s_typename2)
459462
pc_rightbracket2;
460463

461464
if (pc_index1 != NULL && pc_index2 != NULL) {
462-
memset(s_prefix1, '\0', _TYPE_NAME_SIZE + 1);
463-
memset(s_prefix2, '\0', _TYPE_NAME_SIZE + 1);
465+
s_prefix1[0] = s_prefix1[_TYPE_NAME_SIZE] = '\0';
466+
s_prefix2[0] = s_prefix2[_TYPE_NAME_SIZE] = '\0';
464467
strncpy(s_prefix1, s_elemname1, pc_index1 - s_elemname1);
468+
s_prefix1[pc_index1 - s_elemname1] = '\0';
465469
strncpy(s_prefix2, s_elemname2, pc_index2 - s_elemname2);
470+
s_prefix2[pc_index2 - s_elemname2] = '\0';
466471

467472
if (_type_is_registered(s_prefix1) != _type_is_registered(s_prefix2)) {
468473
return false;
469474
}
470475

471-
memset(s_prefix1, '\0', _TYPE_NAME_SIZE + 1);
472-
memset(s_prefix2, '\0', _TYPE_NAME_SIZE + 1);
476+
s_prefix1[0] = s_prefix1[_TYPE_NAME_SIZE] = '\0';
477+
s_prefix2[0] = s_prefix2[_TYPE_NAME_SIZE] = '\0';
473478
strncpy(s_prefix1, pc_index1 + 1, _TYPE_NAME_SIZE);
474479
strncpy(s_prefix2, pc_index2 + 1, _TYPE_NAME_SIZE);
475-
memset(s_elemname1, '\0', _TYPE_NAME_SIZE + 1);
476-
memset(s_elemname2, '\0', _TYPE_NAME_SIZE + 1);
480+
s_elemname1[0] = s_elemname1[_TYPE_NAME_SIZE] = '\0';
481+
s_elemname2[0] = s_elemname2[_TYPE_NAME_SIZE] = '\0';
477482
strncpy(s_elemname1, s_prefix1, _TYPE_NAME_SIZE);
478483
strncpy(s_elemname2, s_prefix2, _TYPE_NAME_SIZE);
479484
} else {

src/cstl_types_aux.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ size_t _type_hash(const char* s_typename)
143143
t_hash = t_hash * _TYPE_HASH_BKDR_SEED + (*s_typename++);
144144
}
145145

146-
return t_hash % _TYPE_REGISTER_BUCKET_COUNT;
146+
return (t_hash & 0x7fffffff) % _TYPE_REGISTER_BUCKET_COUNT;
147147
}
148148

149149
/**

src/cstl_types_builtin.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The implementation of cstl types builtin functions.
3-
* Copyright (C) 2008 - 2012 Wangbo
3+
* Copyright (C) 2008 - 2014 Wangbo
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

src/cstl_vector.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The implement of vector module.
3-
* Copyright (C) 2008 - 2012 Wangbo
3+
* Copyright (C) 2008 - 2014 Wangbo
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

src/cstl_vector_private.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The implement of vector private interface.
3-
* Copyright (C) 2008 - 2012 Wangbo
3+
* Copyright (C) 2008 - 2014 Wangbo
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

0 commit comments

Comments
 (0)