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
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
16 deletions
+13
-16
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
go/zodb/str_test.go
go/zodb/str_test.go
+4
-4
No files found.
go/zodb/buffer.go
View file @
2c03f1f6
...
...
@@ -34,7 +34,7 @@ import (
//
// Custom allocation functions affect only performance, not correctness -
// everything should work if data buffer is allocated and/or free'ed
// regular Go/GC-way.
//
via
regular Go/GC-way.
type
Buf
struct
{
Data
[]
byte
...
...
@@ -54,10 +54,9 @@ func init() {
for
i
:=
0
;
i
<
len
(
bufPoolv
);
i
++
{
i
:=
i
bufPoolv
[
i
]
.
New
=
func
()
interface
{}
{
//println("X allocating for order", i)
// NOTE *Buf, not just buf, to avoid allocation when
// 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() {
}
// order = max i: 2^i <= cap
//order := bits.Len(uint(cap(buf.Data)))
order
:=
xmath
.
FloorLog2
(
uint64
(
cap
(
buf
.
Data
)))
//println("YYY free", cap(buf.Data), "-> order:", order)
order
-=
order0
if
order
<
0
{
...
...
go/zodb/buffer_test.go
View file @
2c03f1f6
...
...
@@ -51,9 +51,9 @@ func TestBufAllocFree(t *testing.T) {
xcap
:=
1
<<
i
buf
:=
BufAlloc
(
size
)
if
i
<
order0
{
xcap
=
1
<<
order0
xcap
=
1
<<
order0
}
if
int
(
i
)
>=
order0
+
len
(
bufPoolv
)
{
if
int
(
i
)
>=
order0
+
len
(
bufPoolv
)
{
xcap
=
size
}
...
...
@@ -80,7 +80,7 @@ func TestBufAllocFree(t *testing.T) {
buf2
:=
BufAlloc
(
size
)
// 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
)
{
t
.
Fatalf
(
"%v: buffer reused but should not"
,
i
)
}
...
...
go/zodb/pydata.go
View file @
2c03f1f6
...
...
@@ -50,14 +50,14 @@ func (d PyData) ClassName() string {
}
if
t
,
ok
:=
xklass
.
(
pickle
.
Tuple
);
ok
{
if
len
(
t
)
!=
2
{
// (klass, args)
if
len
(
t
)
!=
2
{
// (klass, args)
return
"?.?"
}
xklass
=
t
[
0
]
if
t
,
ok
:=
xklass
.
(
pickle
.
Tuple
);
ok
{
// py: "old style reference"
if
len
(
t
)
!=
2
{
return
"?.?"
// (modname, classname)
return
"?.?"
// (modname, classname)
}
return
fmt
.
Sprintf
(
"%s.%s"
,
t
...
)
}
...
...
go/zodb/str.go
View file @
2c03f1f6
...
...
@@ -63,10 +63,10 @@ func (xtid XTid) 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 {
b .C("=<"[bint(xtid.TidBefore)]) .V(xtid.Tid)
}
...
...
go/zodb/str_test.go
View file @
2c03f1f6
...
...
@@ -49,7 +49,7 @@ func TestParseXTid(t *testing.T) {
var
testv
=
[]
struct
{
in
string
;
xtid
XTid
;
estr
string
}
{
{
""
,
XTid
{},
`xtid "" invalid`
},
{
"a"
,
XTid
{},
`xtid "a" invalid`
},
{
"0123456789abcdef"
,
XTid
{},
`xtid "0123456789abcdef" invalid`
},
// XXX or let it be < by default ?
{
"0123456789abcdef"
,
XTid
{},
`xtid "0123456789abcdef" invalid`
},
// XXX or let it be < by default ?
{
"z0123456789abcdef"
,
XTid
{},
`xtid "z0123456789abcdef" invalid`
},
{
"=0123456789abcdef"
,
XTid
{
0x0123456789abcdef
,
false
},
""
},
{
"<0123456789abcdef"
,
XTid
{
0x0123456789abcdef
,
true
},
""
},
...
...
@@ -59,7 +59,7 @@ func TestParseXTid(t *testing.T) {
xtid
,
err
:=
ParseXTid
(
tt
.
in
)
if
!
(
xtid
==
tt
.
xtid
&&
estr
(
err
)
==
tt
.
estr
)
{
t
.
Errorf
(
"parsextid: %v: test error:
\n
have: %v %q
\n
want: %v %q"
,
tt
.
in
,
xtid
,
err
,
tt
.
xtid
,
tt
.
estr
)
tt
.
in
,
xtid
,
err
,
tt
.
xtid
,
tt
.
estr
)
}
}
}
...
...
@@ -68,7 +68,7 @@ func TestParseXid(t *testing.T) {
var
testv
=
[]
struct
{
in
string
;
xid
Xid
;
estr
string
}
{
{
""
,
Xid
{},
`xid "" invalid`
},
{
"a"
,
Xid
{},
`xid "a" invalid`
},
{
"0123456789abcdef"
,
Xid
{},
`xid "0123456789abcdef" invalid`
},
// XXX or let it be < by default ?
{
"0123456789abcdef"
,
Xid
{},
`xid "0123456789abcdef" invalid`
},
// XXX or let it be < by default ?
{
"z0123456789abcdef"
,
Xid
{},
`xid "z0123456789abcdef" invalid`
},
{
"=0123456789abcdef"
,
Xid
{},
`xid "=0123456789abcdef" invalid`
},
{
"<0123456789abcdef"
,
Xid
{},
`xid "<0123456789abcdef" invalid`
},
...
...
@@ -84,7 +84,7 @@ func TestParseXid(t *testing.T) {
xid
,
err
:=
ParseXid
(
tt
.
in
)
if
!
(
xid
==
tt
.
xid
&&
estr
(
err
)
==
tt
.
estr
)
{
t
.
Errorf
(
"parsexid: %v: test error:
\n
have: %v %q
\n
want: %v %q"
,
tt
.
in
,
xid
,
err
,
tt
.
xid
,
tt
.
estr
)
tt
.
in
,
xid
,
err
,
tt
.
xid
,
tt
.
estr
)
}
}
}
...
...
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