Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
ZEO
Commits
d581a972
Commit
d581a972
authored
Feb 16, 2001
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factored out grow method.
parent
0c24cf1f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
30 deletions
+37
-30
src/BTrees/BucketTemplate.c
src/BTrees/BucketTemplate.c
+37
-30
No files found.
src/BTrees/BucketTemplate.c
View file @
d581a972
...
...
@@ -134,6 +134,41 @@ bucket_getitem(Bucket *self, PyObject *key)
return
_bucket_get
(
self
,
key
,
0
);
}
static
int
Bucket_grow
(
Bucket
*
self
,
int
noval
)
{
KEY_TYPE
*
keys
;
VALUE_TYPE
*
values
;
if
(
self
->
size
)
{
UNLESS
(
keys
=
PyRealloc
(
self
->
keys
,
sizeof
(
KEY_TYPE
)
*
self
->
size
*
2
))
return
-
1
;
UNLESS
(
noval
)
{
UNLESS
(
values
=
PyRealloc
(
self
->
values
,
sizeof
(
VALUE_TYPE
)
*
self
->
size
*
2
))
return
-
1
;
self
->
values
=
values
;
}
self
->
keys
=
keys
;
self
->
size
*=
2
;
}
else
{
UNLESS
(
self
->
keys
=
PyMalloc
(
sizeof
(
KEY_TYPE
)
*
MIN_BUCKET_ALLOC
))
return
-
1
;
UNLESS
(
noval
||
(
self
->
values
=
PyMalloc
(
sizeof
(
VALUE_TYPE
)
*
MIN_BUCKET_ALLOC
))
)
return
-
1
;
self
->
size
=
MIN_BUCKET_ALLOC
;
}
return
0
;
}
/*
** _bucket_set
**
...
...
@@ -153,8 +188,6 @@ _bucket_set(Bucket *self, PyObject *keyarg, PyObject *v, int unique, int noval)
{
int
min
,
max
,
i
,
l
,
cmp
,
copied
=
1
;
KEY_TYPE
key
;
KEY_TYPE
*
keys
;
VALUE_TYPE
*
values
;
COPY_KEY_FROM_ARG
(
key
,
keyarg
,
&
copied
);
UNLESS
(
copied
)
return
-
1
;
...
...
@@ -225,34 +258,8 @@ _bucket_set(Bucket *self, PyObject *keyarg, PyObject *v, int unique, int noval)
goto
err
;
}
if
(
self
->
len
==
self
->
size
)
{
if
(
self
->
size
)
{
UNLESS
(
keys
=
PyRealloc
(
self
->
keys
,
sizeof
(
KEY_TYPE
)
*
self
->
size
*
2
))
goto
err
;
UNLESS
(
noval
)
{
UNLESS
(
values
=
PyRealloc
(
self
->
values
,
sizeof
(
VALUE_TYPE
)
*
self
->
size
*
2
))
goto
err
;
self
->
values
=
values
;
}
self
->
keys
=
keys
;
self
->
size
*=
2
;
}
else
{
UNLESS
(
self
->
keys
=
PyMalloc
(
sizeof
(
KEY_TYPE
)
*
MIN_BUCKET_ALLOC
))
goto
err
;
UNLESS
(
noval
||
(
self
->
values
=
PyMalloc
(
sizeof
(
VALUE_TYPE
)
*
MIN_BUCKET_ALLOC
))
)
goto
err
;
self
->
size
=
MIN_BUCKET_ALLOC
;
}
}
if
(
self
->
len
==
self
->
size
&&
Bucket_grow
(
self
,
noval
)
<
0
)
goto
err
;
if
(
max
!=
i
)
i
++
;
if
(
self
->
len
>
i
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment