Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
2c03f1f6
Commit
2c03f1f6
authored
Nov 02, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
e796a2b6
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
12 deletions
+9
-12
go/zodb/buffer.go
go/zodb/buffer.go
+2
-5
go/zodb/buffer_test.go
go/zodb/buffer_test.go
+3
-3
go/zodb/pydata.go
go/zodb/pydata.go
+2
-2
go/zodb/str.go
go/zodb/str.go
+2
-2
No files found.
go/zodb/buffer.go
View file @
2c03f1f6
...
@@ -34,7 +34,7 @@ import (
...
@@ -34,7 +34,7 @@ import (
//
//
// Custom allocation functions affect only performance, not correctness -
// Custom allocation functions affect only performance, not correctness -
// everything should work if data buffer is allocated and/or free'ed
// everything should work if data buffer is allocated and/or free'ed
// regular Go/GC-way.
//
via
regular Go/GC-way.
type
Buf
struct
{
type
Buf
struct
{
Data
[]
byte
Data
[]
byte
...
@@ -54,10 +54,9 @@ func init() {
...
@@ -54,10 +54,9 @@ func init() {
for
i
:=
0
;
i
<
len
(
bufPoolv
);
i
++
{
for
i
:=
0
;
i
<
len
(
bufPoolv
);
i
++
{
i
:=
i
i
:=
i
bufPoolv
[
i
]
.
New
=
func
()
interface
{}
{
bufPoolv
[
i
]
.
New
=
func
()
interface
{}
{
//println("X allocating for order", i)
// NOTE *Buf, not just buf, to avoid allocation when
// NOTE *Buf, not just buf, to avoid allocation when
// making interface{} from it (interface{} wants to always point to heap)
// making interface{} from it (interface{} wants to always point to heap)
return
&
Buf
{
Data
:
make
([]
byte
,
1
<<
(
order0
+
uint
(
i
)))}
return
&
Buf
{
Data
:
make
([]
byte
,
1
<<
(
order0
+
uint
(
i
)))}
}
}
}
}
}
}
...
@@ -116,9 +115,7 @@ func (buf *Buf) Release() {
...
@@ -116,9 +115,7 @@ func (buf *Buf) Release() {
}
}
// order = max i: 2^i <= cap
// order = max i: 2^i <= cap
//order := bits.Len(uint(cap(buf.Data)))
order
:=
xmath
.
FloorLog2
(
uint64
(
cap
(
buf
.
Data
)))
order
:=
xmath
.
FloorLog2
(
uint64
(
cap
(
buf
.
Data
)))
//println("YYY free", cap(buf.Data), "-> order:", order)
order
-=
order0
order
-=
order0
if
order
<
0
{
if
order
<
0
{
...
...
go/zodb/buffer_test.go
View file @
2c03f1f6
...
@@ -51,9 +51,9 @@ func TestBufAllocFree(t *testing.T) {
...
@@ -51,9 +51,9 @@ func TestBufAllocFree(t *testing.T) {
xcap
:=
1
<<
i
xcap
:=
1
<<
i
buf
:=
BufAlloc
(
size
)
buf
:=
BufAlloc
(
size
)
if
i
<
order0
{
if
i
<
order0
{
xcap
=
1
<<
order0
xcap
=
1
<<
order0
}
}
if
int
(
i
)
>=
order0
+
len
(
bufPoolv
)
{
if
int
(
i
)
>=
order0
+
len
(
bufPoolv
)
{
xcap
=
size
xcap
=
size
}
}
...
@@ -80,7 +80,7 @@ func TestBufAllocFree(t *testing.T) {
...
@@ -80,7 +80,7 @@ func TestBufAllocFree(t *testing.T) {
buf2
:=
BufAlloc
(
size
)
buf2
:=
BufAlloc
(
size
)
// not from pool - memory won't be reused
// not from pool - memory won't be reused
if
int
(
i
)
>=
order0
+
len
(
bufPoolv
)
{
if
int
(
i
)
>=
order0
+
len
(
bufPoolv
)
{
if
buf2
==
buf
||
sliceDataPtr
(
buf2
.
Data
)
==
sliceDataPtr
(
data
)
{
if
buf2
==
buf
||
sliceDataPtr
(
buf2
.
Data
)
==
sliceDataPtr
(
data
)
{
t
.
Fatalf
(
"%v: buffer reused but should not"
,
i
)
t
.
Fatalf
(
"%v: buffer reused but should not"
,
i
)
}
}
...
...
go/zodb/pydata.go
View file @
2c03f1f6
go/zodb/str.go
View file @
2c03f1f6
...
@@ -63,10 +63,10 @@ func (xtid XTid) String() string {
...
@@ -63,10 +63,10 @@ func (xtid XTid) String() string {
}
}
func
(
xid
Xid
)
String
()
string
{
func
(
xid
Xid
)
String
()
string
{
return
xid
.
XTid
.
String
()
+
":"
+
xid
.
Oid
.
String
()
// XXX use "·" instead of ":" ?
return
xid
.
XTid
.
String
()
+
":"
+
xid
.
Oid
.
String
()
}
}
/* TODO reenable
/* TODO reenable
?
func (xtid XTid) XFmtString(b []byte) []byte {
func (xtid XTid) XFmtString(b []byte) []byte {
b .C("=<"[bint(xtid.TidBefore)]) .V(xtid.Tid)
b .C("=<"[bint(xtid.TidBefore)]) .V(xtid.Tid)
}
}
...
...
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