Skip to content

Commit 33b90c4

Browse files
authored
Merge pull request #52 from soluchok/improves_performance
perf: Improves performance for big documents
2 parents 965530e + 387195c commit 33b90c4

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

ld/api_normalize.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,12 @@ func (na *NormalisationAlgorithm) Main(dataset *RDFDataset, opts *JsonLdOptions)
279279
return nil, NewJsonLdError(UnknownFormat, opts.Format)
280280
}
281281
}
282-
rval := ""
282+
var rval []byte
283283
for _, n := range na.lines {
284-
rval += n
284+
rval = append(rval, []byte(n)...)
285285
}
286-
return ParseNQuads(rval)
286+
287+
return ParseNQuads(string(rval))
287288
}
288289

289290
// Sort interface

ld/context.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
var (
2525
ignoredKeywordPattern = regexp.MustCompile("^@[a-zA-Z]+$")
2626
invalidPrefixPattern = regexp.MustCompile(":|/")
27-
iriLikeTermPattern = regexp.MustCompile(`(?::[^:])|\/`)
27+
iriLikeTermPattern = regexp.MustCompile(`(?::[^:])|\/`)
2828

2929
nonTermDefKeys = map[string]bool{
3030
"@base": true,
@@ -696,7 +696,7 @@ func (c *Context) createTermDefinition(context map[string]interface{}, term stri
696696
termHasSuffix := false
697697
if len(res) > 0 {
698698
switch res[len(res)-1] {
699-
case ':', '/', '?', '#', '[', ']','@':
699+
case ':', '/', '?', '#', '[', ']', '@':
700700
termHasSuffix = true
701701
default:
702702
termHasSuffix = false

ld/node.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ func NewLiteral(value string, datatype string, language string) *Literal {
5959
}
6060

6161
// GetValue returns the node's value.
62-
func (l Literal) GetValue() string {
62+
func (l *Literal) GetValue() string {
6363
return l.Value
6464
}
6565

6666
// Equal returns true id this node is equal to the given node.
67-
func (l Literal) Equal(n Node) bool {
67+
func (l *Literal) Equal(n Node) bool {
6868
ol, ok := n.(*Literal)
6969
if !ok {
7070
return false
@@ -100,12 +100,12 @@ func NewIRI(iri string) *IRI {
100100
}
101101

102102
// GetValue returns the node's value.
103-
func (iri IRI) GetValue() string {
103+
func (iri *IRI) GetValue() string {
104104
return iri.Value
105105
}
106106

107107
// Equal returns true id this node is equal to the given node.
108-
func (iri IRI) Equal(n Node) bool {
108+
func (iri *IRI) Equal(n Node) bool {
109109
if oiri, ok := n.(*IRI); ok {
110110
return iri.Value == oiri.Value
111111
}
@@ -128,12 +128,12 @@ func NewBlankNode(attribute string) *BlankNode {
128128
}
129129

130130
// GetValue returns the node's value.
131-
func (bn BlankNode) GetValue() string {
131+
func (bn *BlankNode) GetValue() string {
132132
return bn.Attribute
133133
}
134134

135135
// Equal returns true id this node is equal to the given node.
136-
func (bn BlankNode) Equal(n Node) bool {
136+
func (bn *BlankNode) Equal(n Node) bool {
137137
if obn, ok := n.(*BlankNode); ok {
138138
return bn.Attribute == obn.Attribute
139139
}

ld/rdf_dataset.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func NewQuad(subject Node, predicate Node, object Node, graph string) *Quad {
5252
}
5353

5454
// Equal returns true if this quad is equal to the given quad.
55-
func (q Quad) Equal(o *Quad) bool {
55+
func (q *Quad) Equal(o *Quad) bool {
5656
if o == nil {
5757
return false
5858
}
@@ -64,7 +64,7 @@ func (q Quad) Equal(o *Quad) bool {
6464
return q.Subject.Equal(o.Subject) && q.Predicate.Equal(o.Predicate) && q.Object.Equal(o.Object)
6565
}
6666

67-
func (q Quad) Valid() bool {
67+
func (q *Quad) Valid() bool {
6868
if q.Subject != nil {
6969
if InvalidNode(q.Subject) {
7070
return false

0 commit comments

Comments
 (0)