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
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 (
...
@@ -32,8 +32,8 @@ import (
"../../../../storage/fs1"
"../../../../storage/fs1"
"../../../../xcommon/xbufio"
"../../../../xcommon/xbufio"
"../../../../xcommon/xbytes"
"../../../../xcommon/xfmt"
"../../../../xcommon/xfmt"
"../../../../xcommon/xslice"
)
)
...
@@ -105,7 +105,7 @@ func fsTail(w io.Writer, path string, ntxn int) (err error) {
...
@@ -105,7 +105,7 @@ func fsTail(w io.Writer, path string, ntxn int) (err error) {
// read raw data inside transaction record
// read raw data inside transaction record
dataLen
:=
txnh
.
DataLen
()
dataLen
:=
txnh
.
DataLen
()
data
=
x
slice
.
Realloc64
(
data
,
dataLen
)
data
=
x
bytes
.
Realloc64
(
data
,
dataLen
)
_
,
err
=
fSeq
.
ReadAt
(
data
,
txnh
.
DataPos
())
_
,
err
=
fSeq
.
ReadAt
(
data
,
txnh
.
DataPos
())
if
err
!=
nil
{
if
err
!=
nil
{
// XXX -> txnh.Err(...) ?
// XXX -> txnh.Err(...) ?
...
...
t/neo/storage/fs1/filestorage.go
View file @
f1278d15
...
@@ -24,7 +24,7 @@ import (
...
@@ -24,7 +24,7 @@ import (
"../../zodb"
"../../zodb"
"../../xcommon/xbufio"
"../../xcommon/xbufio"
"../../xcommon/x
slice
"
"../../xcommon/x
bytes
"
)
)
// FileStorage is a ZODB storage which stores data in simple append-only file
// FileStorage is a ZODB storage which stores data in simple append-only file
...
@@ -194,7 +194,7 @@ func (txnh *TxnHeader) DataLen() int64 {
...
@@ -194,7 +194,7 @@ func (txnh *TxnHeader) DataLen() int64 {
func
(
txnh
*
TxnHeader
)
CloneFrom
(
txnh2
*
TxnHeader
)
{
func
(
txnh
*
TxnHeader
)
CloneFrom
(
txnh2
*
TxnHeader
)
{
workMem
:=
txnh
.
workMem
workMem
:=
txnh
.
workMem
lwork2
:=
len
(
txnh2
.
workMem
)
lwork2
:=
len
(
txnh2
.
workMem
)
workMem
=
x
slice
.
Realloc
(
workMem
,
lwork2
)
workMem
=
x
bytes
.
Realloc
(
workMem
,
lwork2
)
*
txnh
=
*
txnh2
*
txnh
=
*
txnh2
// now unshare slices
// now unshare slices
txnh
.
workMem
=
workMem
txnh
.
workMem
=
workMem
...
@@ -311,7 +311,7 @@ func (txnh *TxnHeader) Load(r io.ReaderAt /* *os.File */, pos int64, flags TxnLo
...
@@ -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)
// 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)
// NOTE we encode each x string length into cap(x)
// and set len(x) = 0 to indicate x is not loaded yet
// 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
...
@@ -646,7 +646,7 @@ func (dh *DataHeader) LoadData(r io.ReaderAt /* *os.File */, buf *[]byte) error
}
}
// now read actual data
// 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
)
_
,
err
:=
r
.
ReadAt
(
*
buf
,
dh
.
Pos
+
DataHeaderSize
)
if
err
!=
nil
{
if
err
!=
nil
{
return
dh
.
err
(
"read data"
,
noEOF
(
err
))
// XXX recheck
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 @@
...
@@ -15,9 +15,9 @@
//
//
// See COPYING file for full licensing terms.
// See COPYING file for full licensing terms.
//
Package xbytes provides addons to std package bytes
//
(re)allocation routines for []byte
// Package xbytes provides additional utilities for working with (XXX byte) slices
package
x
slice
package
x
bytes
import
(
import
(
"../xmath"
"../xmath"
...
...
t/neo/xcommon/x
slice/slice
_test.go
→
t/neo/xcommon/x
bytes/alloc
_test.go
View file @
f1278d15
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
//
//
// See COPYING file for full licensing terms.
// See COPYING file for full licensing terms.
package
x
slice
package
x
bytes
import
(
import
(
"bytes"
"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 (
...
@@ -36,7 +36,7 @@ import (
"strconv"
"strconv"
"unicode/utf8"
"unicode/utf8"
"../x
slice
"
"../x
bytes
"
"lab.nexedi.com/kirr/go123/mem"
"lab.nexedi.com/kirr/go123/mem"
)
)
...
@@ -127,7 +127,7 @@ func (b *Buffer) Cb(c byte) *Buffer {
...
@@ -127,7 +127,7 @@ func (b *Buffer) Cb(c byte) *Buffer {
// AppendRune appends to b UTF-8 encoding of r
// AppendRune appends to b UTF-8 encoding of r
func
AppendRune
(
b
[]
byte
,
r
rune
)
[]
byte
{
func
AppendRune
(
b
[]
byte
,
r
rune
)
[]
byte
{
l
:=
len
(
b
)
l
:=
len
(
b
)
b
=
x
slice
.
Grow
(
b
,
utf8
.
UTFMax
)
b
=
x
bytes
.
Grow
(
b
,
utf8
.
UTFMax
)
n
:=
utf8
.
EncodeRune
(
b
[
l
:
],
r
)
n
:=
utf8
.
EncodeRune
(
b
[
l
:
],
r
)
return
b
[
:
l
+
n
]
return
b
[
:
l
+
n
]
}
}
...
@@ -160,7 +160,7 @@ func (b *Buffer) X(i int) *Buffer {
...
@@ -160,7 +160,7 @@ func (b *Buffer) X(i int) *Buffer {
func
AppendHex
(
b
[]
byte
,
x
[]
byte
)
[]
byte
{
func
AppendHex
(
b
[]
byte
,
x
[]
byte
)
[]
byte
{
lx
:=
hex
.
EncodedLen
(
len
(
x
))
lx
:=
hex
.
EncodedLen
(
len
(
x
))
lb
:=
len
(
b
)
lb
:=
len
(
b
)
b
=
x
slice
.
Grow
(
b
,
lx
)
b
=
x
bytes
.
Grow
(
b
,
lx
)
hex
.
Encode
(
b
[
lb
:
],
x
)
hex
.
Encode
(
b
[
lb
:
],
x
)
return
b
return
b
}
}
...
@@ -182,7 +182,7 @@ func (b *Buffer) Xs(x string) *Buffer {
...
@@ -182,7 +182,7 @@ func (b *Buffer) Xs(x string) *Buffer {
func
AppendHex016
(
b
[]
byte
,
x
uint64
)
[]
byte
{
func
AppendHex016
(
b
[]
byte
,
x
uint64
)
[]
byte
{
// like sprintf("%016x") but faster and less allocations
// like sprintf("%016x") but faster and less allocations
l
:=
len
(
b
)
l
:=
len
(
b
)
b
=
x
slice
.
Grow
(
b
,
16
)
b
=
x
bytes
.
Grow
(
b
,
16
)
bb
:=
b
[
l
:
]
bb
:=
b
[
l
:
]
for
i
:=
15
;
i
>=
0
;
i
--
{
for
i
:=
15
;
i
>=
0
;
i
--
{
bb
[
i
]
=
hexdigits
[
x
&
0xf
]
bb
[
i
]
=
hexdigits
[
x
&
0xf
]
...
...
t/neo/xcommon/xfmt/python.go
View file @
f1278d15
...
@@ -20,18 +20,13 @@
...
@@ -20,18 +20,13 @@
package
xfmt
package
xfmt
import
(
import
(
"bytes"
"strconv"
"strconv"
"unicode/utf8"
"unicode/utf8"
"lab.nexedi.com/kirr/go123/mem"
"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
// AppendQuotePy appends to buf Python quoting of s
func
AppendQuotePy
(
buf
[]
byte
,
s
string
)
[]
byte
{
func
AppendQuotePy
(
buf
[]
byte
,
s
string
)
[]
byte
{
return
AppendQuotePyBytes
(
buf
,
mem
.
Bytes
(
s
))
return
AppendQuotePyBytes
(
buf
,
mem
.
Bytes
(
s
))
...
@@ -42,7 +37,7 @@ func AppendQuotePyBytes(buf, b []byte) []byte {
...
@@ -42,7 +37,7 @@ func AppendQuotePyBytes(buf, b []byte) []byte {
// smartquotes: choose ' or " as quoting character
// smartquotes: choose ' or " as quoting character
// https://github.com/python/cpython/blob/v2.7.13-116-g1aa1803b3d/Objects/stringobject.c#L947
// https://github.com/python/cpython/blob/v2.7.13-116-g1aa1803b3d/Objects/stringobject.c#L947
quote
:=
byte
(
'\'
'
)
quote
:=
byte
(
'\'
'
)
if
bytesContainsByte
(
b
,
'\'
'
)
&&
!
bytes
ContainsByte
(
b
,
'"'
)
{
if
xbytes
.
ContainsByte
(
b
,
'\'
'
)
&&
!
xbytes
.
ContainsByte
(
b
,
'"'
)
{
quote
=
'"'
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