Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
f1278d15
Commit
f1278d15
authored
Apr 20, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
0332d46d
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
44 additions
and
21 deletions
+44
-21
t/neo/storage/fs1/cmd/fstail/fstail.go
t/neo/storage/fs1/cmd/fstail/fstail.go
+2
-2
t/neo/storage/fs1/filestorage.go
t/neo/storage/fs1/filestorage.go
+4
-4
t/neo/xcommon/xbytes/alloc.go
t/neo/xcommon/xbytes/alloc.go
+3
-3
t/neo/xcommon/xbytes/alloc_test.go
t/neo/xcommon/xbytes/alloc_test.go
+1
-1
t/neo/xcommon/xbytes/bytes.go
t/neo/xcommon/xbytes/bytes.go
+28
-0
t/neo/xcommon/xfmt/fmt.go
t/neo/xcommon/xfmt/fmt.go
+4
-4
t/neo/xcommon/xfmt/python.go
t/neo/xcommon/xfmt/python.go
+2
-7
No files found.
t/neo/storage/fs1/cmd/fstail/fstail.go
View file @
f1278d15
...
...
@@ -32,8 +32,8 @@ import (
"../../../../storage/fs1"
"../../../../xcommon/xbufio"
"../../../../xcommon/xbytes"
"../../../../xcommon/xfmt"
"../../../../xcommon/xslice"
)
...
...
@@ -105,7 +105,7 @@ func fsTail(w io.Writer, path string, ntxn int) (err error) {
// read raw data inside transaction record
dataLen
:=
txnh
.
DataLen
()
data
=
x
slice
.
Realloc64
(
data
,
dataLen
)
data
=
x
bytes
.
Realloc64
(
data
,
dataLen
)
_
,
err
=
fSeq
.
ReadAt
(
data
,
txnh
.
DataPos
())
if
err
!=
nil
{
// XXX -> txnh.Err(...) ?
...
...
t/neo/storage/fs1/filestorage.go
View file @
f1278d15
...
...
@@ -24,7 +24,7 @@ import (
"../../zodb"
"../../xcommon/xbufio"
"../../xcommon/x
slice
"
"../../xcommon/x
bytes
"
)
// FileStorage is a ZODB storage which stores data in simple append-only file
...
...
@@ -194,7 +194,7 @@ func (txnh *TxnHeader) DataLen() int64 {
func
(
txnh
*
TxnHeader
)
CloneFrom
(
txnh2
*
TxnHeader
)
{
workMem
:=
txnh
.
workMem
lwork2
:=
len
(
txnh2
.
workMem
)
workMem
=
x
slice
.
Realloc
(
workMem
,
lwork2
)
workMem
=
x
bytes
.
Realloc
(
workMem
,
lwork2
)
*
txnh
=
*
txnh2
// now unshare slices
txnh
.
workMem
=
workMem
...
...
@@ -311,7 +311,7 @@ func (txnh *TxnHeader) Load(r io.ReaderAt /* *os.File */, pos int64, flags TxnLo
}
// NOTE we encode whole strings length into len(.workMem)
txnh
.
workMem
=
x
slice
.
Realloc
(
txnh
.
workMem
,
lstr
)
txnh
.
workMem
=
x
bytes
.
Realloc
(
txnh
.
workMem
,
lstr
)
// NOTE we encode each x string length into cap(x)
// and set len(x) = 0 to indicate x is not loaded yet
...
...
@@ -646,7 +646,7 @@ func (dh *DataHeader) LoadData(r io.ReaderAt /* *os.File */, buf *[]byte) error
}
// now read actual data
*
buf
=
x
slice
.
Realloc64
(
*
buf
,
dh
.
DataLen
)
*
buf
=
x
bytes
.
Realloc64
(
*
buf
,
dh
.
DataLen
)
_
,
err
:=
r
.
ReadAt
(
*
buf
,
dh
.
Pos
+
DataHeaderSize
)
if
err
!=
nil
{
return
dh
.
err
(
"read data"
,
noEOF
(
err
))
// XXX recheck
...
...
t/neo/xcommon/x
slice/slice
.go
→
t/neo/xcommon/x
bytes/alloc
.go
View file @
f1278d15
...
...
@@ -15,9 +15,9 @@
//
// See COPYING file for full licensing terms.
//
Package xbytes provides addons to std package bytes
// Package xbytes provides additional utilities for working with (XXX byte) slices
package
x
slice
//
(re)allocation routines for []byte
package
x
bytes
import
(
"../xmath"
...
...
t/neo/xcommon/x
slice/slice
_test.go
→
t/neo/xcommon/x
bytes/alloc
_test.go
View file @
f1278d15
...
...
@@ -15,7 +15,7 @@
//
// See COPYING file for full licensing terms.
package
x
slice
package
x
bytes
import
(
"bytes"
...
...
t/neo/xcommon/xbytes/bytes.go
0 → 100644
View file @
f1278d15
// Copyright (C) 2017 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Open Source Initiative approved licenses and Convey
// the resulting work. Corresponding source of such a combination shall include
// the source code for all other software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
// Package xbytes provides additional utilities for working with byte slices
package
xbytes
import
(
"bytes"
)
// ContainsByte is like bytes.ContainsRune but a bit faster
func
ContainsByte
(
s
[]
byte
,
c
byte
)
bool
{
return
bytes
.
IndexByte
(
s
,
c
)
>=
0
}
t/neo/xcommon/xfmt/fmt.go
View file @
f1278d15
...
...
@@ -36,7 +36,7 @@ import (
"strconv"
"unicode/utf8"
"../x
slice
"
"../x
bytes
"
"lab.nexedi.com/kirr/go123/mem"
)
...
...
@@ -127,7 +127,7 @@ func (b *Buffer) Cb(c byte) *Buffer {
// AppendRune appends to b UTF-8 encoding of r
func
AppendRune
(
b
[]
byte
,
r
rune
)
[]
byte
{
l
:=
len
(
b
)
b
=
x
slice
.
Grow
(
b
,
utf8
.
UTFMax
)
b
=
x
bytes
.
Grow
(
b
,
utf8
.
UTFMax
)
n
:=
utf8
.
EncodeRune
(
b
[
l
:
],
r
)
return
b
[
:
l
+
n
]
}
...
...
@@ -160,7 +160,7 @@ func (b *Buffer) X(i int) *Buffer {
func
AppendHex
(
b
[]
byte
,
x
[]
byte
)
[]
byte
{
lx
:=
hex
.
EncodedLen
(
len
(
x
))
lb
:=
len
(
b
)
b
=
x
slice
.
Grow
(
b
,
lx
)
b
=
x
bytes
.
Grow
(
b
,
lx
)
hex
.
Encode
(
b
[
lb
:
],
x
)
return
b
}
...
...
@@ -182,7 +182,7 @@ func (b *Buffer) Xs(x string) *Buffer {
func
AppendHex016
(
b
[]
byte
,
x
uint64
)
[]
byte
{
// like sprintf("%016x") but faster and less allocations
l
:=
len
(
b
)
b
=
x
slice
.
Grow
(
b
,
16
)
b
=
x
bytes
.
Grow
(
b
,
16
)
bb
:=
b
[
l
:
]
for
i
:=
15
;
i
>=
0
;
i
--
{
bb
[
i
]
=
hexdigits
[
x
&
0xf
]
...
...
t/neo/xcommon/xfmt/python.go
View file @
f1278d15
...
...
@@ -20,18 +20,13 @@
package
xfmt
import
(
"bytes"
"strconv"
"unicode/utf8"
"lab.nexedi.com/kirr/go123/mem"
"../xbytes"
)
// bytesContainsByte is like bytes.ContainsRune but a bit faster
func
bytesContainsByte
(
s
[]
byte
,
c
byte
)
bool
{
return
bytes
.
IndexByte
(
s
,
c
)
>=
0
}
// AppendQuotePy appends to buf Python quoting of s
func
AppendQuotePy
(
buf
[]
byte
,
s
string
)
[]
byte
{
return
AppendQuotePyBytes
(
buf
,
mem
.
Bytes
(
s
))
...
...
@@ -42,7 +37,7 @@ func AppendQuotePyBytes(buf, b []byte) []byte {
// smartquotes: choose ' or " as quoting character
// https://github.com/python/cpython/blob/v2.7.13-116-g1aa1803b3d/Objects/stringobject.c#L947
quote
:=
byte
(
'\'
'
)
if
bytesContainsByte
(
b
,
'\'
'
)
&&
!
bytes
ContainsByte
(
b
,
'"'
)
{
if
xbytes
.
ContainsByte
(
b
,
'\'
'
)
&&
!
xbytes
.
ContainsByte
(
b
,
'"'
)
{
quote
=
'"'
}
...
...
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