Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
12e411f8
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
12e411f8
编写于
3月 12, 2021
作者:
M
Maksim Kita
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
PODArray swap fix
上级
289712f1
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
26 addition
and
16 deletion
+26
-16
src/Common/PODArray.h
src/Common/PODArray.h
+26
-16
未找到文件。
src/Common/PODArray.h
浏览文件 @
12e411f8
...
...
@@ -568,7 +568,7 @@ public:
/// arr1 takes ownership of the heap memory of arr2.
arr1
.
c_start
=
arr2
.
c_start
;
arr1
.
c_end_of_storage
=
arr1
.
c_start
+
heap_allocated
-
arr
1
.
pad_righ
t
;
arr1
.
c_end_of_storage
=
arr1
.
c_start
+
heap_allocated
-
arr
2
.
pad_right
-
arr2
.
pad_lef
t
;
arr1
.
c_end
=
arr1
.
c_start
+
this
->
byte_size
(
heap_size
);
/// Allocate stack space for arr2.
...
...
@@ -585,7 +585,7 @@ public:
dest
.
dealloc
();
dest
.
alloc
(
src
.
allocated_bytes
(),
std
::
forward
<
TAllocatorParams
>
(
allocator_params
)...);
memcpy
(
dest
.
c_start
,
src
.
c_start
,
this
->
byte_size
(
src
.
size
()));
dest
.
c_end
=
dest
.
c_start
+
(
src
.
c_end
-
src
.
c_start
);
dest
.
c_end
=
dest
.
c_start
+
this
->
byte_size
(
src
.
size
()
);
src
.
c_start
=
Base
::
null
;
src
.
c_end
=
Base
::
null
;
...
...
@@ -597,6 +597,11 @@ public:
std
::
swap
(
dest
.
c_end
,
src
.
c_end
);
std
::
swap
(
dest
.
c_end_of_storage
,
src
.
c_end_of_storage
);
}
#ifndef NDEBUG
this
->
protect
();
rhs
.
protect
();
#endif
};
if
(
!
this
->
isInitialized
()
&&
!
rhs
.
isInitialized
())
...
...
@@ -639,8 +644,8 @@ public:
size_t
rhs_size
=
rhs
.
size
();
size_t
rhs_allocated
=
rhs
.
allocated_bytes
();
this
->
c_end_of_storage
=
this
->
c_start
+
rhs_allocated
-
Base
::
pad_right
;
rhs
.
c_end_of_storage
=
rhs
.
c_start
+
lhs_allocated
-
Base
::
pad_right
;
this
->
c_end_of_storage
=
this
->
c_start
+
rhs_allocated
-
Base
::
pad_right
-
Base
::
pad_left
;
rhs
.
c_end_of_storage
=
rhs
.
c_start
+
lhs_allocated
-
Base
::
pad_right
-
Base
::
pad_left
;
this
->
c_end
=
this
->
c_start
+
this
->
byte_size
(
rhs_size
);
rhs
.
c_end
=
rhs
.
c_start
+
this
->
byte_size
(
lhs_size
);
...
...
@@ -659,6 +664,11 @@ public:
std
::
swap
(
this
->
c_end
,
rhs
.
c_end
);
std
::
swap
(
this
->
c_end_of_storage
,
rhs
.
c_end_of_storage
);
}
#ifndef NDEBUG
this
->
protect
();
rhs
.
protect
();
#endif
}
template
<
typename
...
TAllocatorParams
>
...
...
@@ -693,34 +703,34 @@ public:
}
bool
operator
==
(
const
PODArray
&
other
)
const
bool
operator
==
(
const
PODArray
&
rhs
)
const
{
if
(
this
->
size
()
!=
other
.
size
())
if
(
this
->
size
()
!=
rhs
.
size
())
return
false
;
const_iterator
thi
s_it
=
begin
();
const_iterator
that_it
=
other
.
begin
();
const_iterator
lh
s_it
=
begin
();
const_iterator
rhs_it
=
rhs
.
begin
();
while
(
thi
s_it
!=
end
())
while
(
lh
s_it
!=
end
())
{
if
(
*
this_it
!=
*
that
_it
)
if
(
*
lhs_it
!=
*
rhs
_it
)
return
false
;
++
thi
s_it
;
++
that
_it
;
++
lh
s_it
;
++
rhs
_it
;
}
return
true
;
}
bool
operator
!=
(
const
PODArray
&
other
)
const
bool
operator
!=
(
const
PODArray
&
rhs
)
const
{
return
!
operator
==
(
other
);
return
!
operator
==
(
rhs
);
}
};
template
<
typename
T
,
size_t
initial_bytes
,
typename
TAllocator
,
size_t
pad_right_
>
void
swap
(
PODArray
<
T
,
initial_bytes
,
TAllocator
,
pad_right_
>
&
lhs
,
PODArray
<
T
,
initial_bytes
,
TAllocator
,
pad_righ
t_
>
&
rhs
)
template
<
typename
T
,
size_t
initial_bytes
,
typename
TAllocator
,
size_t
pad_right_
,
size_t
pad_left_
>
void
swap
(
PODArray
<
T
,
initial_bytes
,
TAllocator
,
pad_right_
,
pad_left_
>
&
lhs
,
PODArray
<
T
,
initial_bytes
,
TAllocator
,
pad_right_
,
pad_lef
t_
>
&
rhs
)
{
lhs
.
swap
(
rhs
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录