| 8965 | } |
| 8966 | |
| 8967 | void remove_duplicates(xpath_allocator* alloc) |
| 8968 | { |
| 8969 | if (_type == xpath_node_set::type_unsorted && _end - _begin > 2) |
| 8970 | { |
| 8971 | xpath_allocator_capture cr(alloc); |
| 8972 | |
| 8973 | size_t size_ = static_cast<size_t>(_end - _begin); |
| 8974 | |
| 8975 | size_t hash_size = 1; |
| 8976 | while (hash_size < size_ + size_ / 2) hash_size *= 2; |
| 8977 | |
| 8978 | const void** hash_data = static_cast<const void**>(alloc->allocate(hash_size * sizeof(void**))); |
| 8979 | if (!hash_data) return; |
| 8980 | |
| 8981 | memset(hash_data, 0, hash_size * sizeof(const void**)); |
| 8982 | |
| 8983 | xpath_node* write = _begin; |
| 8984 | |
| 8985 | for (xpath_node* it = _begin; it != _end; ++it) |
| 8986 | { |
| 8987 | const void* attr = it->attribute().internal_object(); |
| 8988 | const void* node = it->node().internal_object(); |
| 8989 | const void* key = attr ? attr : node; |
| 8990 | |
| 8991 | if (key && hash_insert(hash_data, hash_size, key)) |
| 8992 | { |
| 8993 | *write++ = *it; |
| 8994 | } |
| 8995 | } |
| 8996 | |
| 8997 | _end = write; |
| 8998 | } |
| 8999 | else |
| 9000 | { |
| 9001 | _end = unique(_begin, _end); |
| 9002 | } |
| 9003 | } |
| 9004 | |
| 9005 | xpath_node_set::type_t type() const |
| 9006 | { |
no test coverage detected