| 41 | } |
| 42 | |
| 43 | void diff_manager::diff_changes(const std::vector<diff_object*>& curr_objs, |
| 44 | const std::vector<diff_object*>& old_objs) |
| 45 | { |
| 46 | size_t size = curr_objs.size() + old_objs.size(); |
| 47 | |
| 48 | // һ����Ԥ��������ռ䣬���������ӹ������ڴ����·��� |
| 49 | objs_equ_.reserve(size + 1); |
| 50 | objs_new_.reserve(size + 1); |
| 51 | objs_del_.reserve(size + 1); |
| 52 | objs_upd_.reserve(size + 1); |
| 53 | objs_new_extra_.reserve(size + 1); |
| 54 | objs_del_extra_.reserve(size + 1); |
| 55 | objs_upd_extra_.reserve(size + 1); |
| 56 | |
| 57 | const char* key; |
| 58 | |
| 59 | // ������ϣ�������������е�Ԫ�����ӽ���ϣ���� |
| 60 | |
| 61 | ACL_HTABLE *htable = acl_htable_create((int) size * 2 + 1, |
| 62 | ACL_HTABLE_FLAG_KEY_REUSE); |
| 63 | |
| 64 | for (std::vector<diff_object*>::const_iterator cit = old_objs.begin(); |
| 65 | cit != old_objs.end(); ++cit) { |
| 66 | |
| 67 | key = (const char* ) (*cit)->get_key(); |
| 68 | (void) acl_htable_enter(htable, key, (void*) *cit); |
| 69 | } |
| 70 | |
| 71 | ACL_HTABLE_INFO* entry; |
| 72 | diff_object* obj; |
| 73 | |
| 74 | // ������ǰ�����еĶ���֮��ɶ��Ͻ��бȽϣ��ҳ������ģ��ɵ� |
| 75 | // �Լ��仯�Ķ��� |
| 76 | for (std::vector<diff_object*>::const_iterator cit = curr_objs.begin(); |
| 77 | cit != curr_objs.end(); ++cit) { |
| 78 | |
| 79 | key = (*cit)->get_key(); |
| 80 | |
| 81 | // �ھɼ����в�ѯ��ǰ�����Ƿ���� |
| 82 | // obj = (diff_object*) acl_htable_find(htable, key); |
| 83 | entry = acl_htable_locate(htable, key); |
| 84 | |
| 85 | // ��������ڣ���˵���ö���Ϊ�¶����ö�����Ϊ�����Ӷ��� |
| 86 | // ���ӽ��¶����� |
| 87 | if (entry == NULL) { |
| 88 | if ((*cit)->check_range(range_from_, range_to_)) { |
| 89 | objs_new_extra_.push_back(*cit); |
| 90 | } else { |
| 91 | objs_new_.push_back(*cit); |
| 92 | } |
| 93 | continue; |
| 94 | } |
| 95 | |
| 96 | obj = (diff_object*) entry->value; |
| 97 | |
| 98 | // �����ǰ������ɶ�����ͬ���ö��������ͬ�����У� |
| 99 | // ͬʱ��֮�ӵ�ǰ���ϼ��ɶ��ϣ���ϣ���ϣ���ɾ�� |
| 100 | if (*obj == **cit) { |
no test coverage detected