Skip to content

Commit

Permalink
fluent/quip: remove in favor of qp
Browse files Browse the repository at this point in the history
After experimenting with quip and qp for a few months, we seem to agree
that qp is a bit nicer to use. Remove quip, since it's largely redundant
going forward.

Since the qp docs referenced quip, redo that to stand on its own ground.
  • Loading branch information
mvdan committed Jul 1, 2021
1 parent e798ae8 commit b7347f1
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 545 deletions.
91 changes: 0 additions & 91 deletions fluent/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,100 +8,9 @@ import (
"github.com/ipld/go-ipld-prime/codec/dagjson"
"github.com/ipld/go-ipld-prime/fluent"
"github.com/ipld/go-ipld-prime/fluent/qp"
"github.com/ipld/go-ipld-prime/fluent/quip"
basicnode "github.com/ipld/go-ipld-prime/node/basic"
)

func BenchmarkQuip(b *testing.B) {
b.ReportAllocs()

f2 := func(na ipld.NodeAssembler, a string, b string, c string, d []string) (err error) {
quip.AssembleMap(&err, na, 4, func(ma ipld.MapAssembler) {
quip.AssignMapEntryString(&err, ma, "destination", a)
quip.AssignMapEntryString(&err, ma, "type", b)
quip.AssignMapEntryString(&err, ma, "source", c)
quip.AssembleMapEntry(&err, ma, "options", func(va ipld.NodeAssembler) {
quip.AssembleList(&err, va, int64(len(d)), func(la ipld.ListAssembler) {
for i := range d {
quip.AssignListEntryString(&err, la, d[i])
}
})
})
})
return
}
var n ipld.Node
var err error
for i := 0; i < b.N; i++ {
n = quip.BuildList(&err, basicnode.Prototype.Any, -1, func(la ipld.ListAssembler) {
f2(la.AssembleValue(),
"/",
"overlay",
"none",
[]string{
"lowerdir=" + "/",
"upperdir=" + "/tmp/overlay-root/upper",
"workdir=" + "/tmp/overlay-root/work",
},
)
})
}
_ = n
if err != nil {
b.Fatal(err)
}
}

func BenchmarkQuipWithoutScalarFuncs(b *testing.B) {
b.ReportAllocs()

// This is simply a slightly longer way of writing the same thing.
// Just for curiosity and to track if there's any measureable performance difference.
f2 := func(na ipld.NodeAssembler, a string, b string, c string, d []string) (err error) {
quip.AssembleMap(&err, na, 4, func(ma ipld.MapAssembler) {
quip.AssembleMapEntry(&err, ma, "destination", func(va ipld.NodeAssembler) {
quip.AbsorbError(&err, va.AssignString(a))
})
quip.AssembleMapEntry(&err, ma, "type", func(va ipld.NodeAssembler) {
quip.AbsorbError(&err, va.AssignString(b))
})
quip.AssembleMapEntry(&err, ma, "source", func(va ipld.NodeAssembler) {
quip.AbsorbError(&err, va.AssignString(c))
})
quip.AssembleMapEntry(&err, ma, "options", func(va ipld.NodeAssembler) {
quip.AssembleList(&err, va, int64(len(d)), func(la ipld.ListAssembler) {
for i := range d {
quip.AssembleListEntry(&err, la, func(va ipld.NodeAssembler) {
quip.AbsorbError(&err, va.AssignString(d[i]))
})
}
})
})
})
return
}
var n ipld.Node
var err error
for i := 0; i < b.N; i++ {
n = quip.BuildList(&err, basicnode.Prototype.Any, -1, func(la ipld.ListAssembler) {
f2(la.AssembleValue(), // TODO: forgot to check error?
"/",
"overlay",
"none",
[]string{
"lowerdir=" + "/",
"upperdir=" + "/tmp/overlay-root/upper",
"workdir=" + "/tmp/overlay-root/work",
},
)
})
}
_ = n
if err != nil {
b.Fatal(err)
}
}

func BenchmarkQp(b *testing.B) {
b.ReportAllocs()

Expand Down
14 changes: 13 additions & 1 deletion fluent/qp/qp.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
// qp is similar to fluent/quip, but with a bit more magic.
// qp helps to quickly build IPLD nodes.
//
// It contains top-level Build funcs, such as BuildMap and BuildList, which
// return the final node as well as an error.
//
// Underneath, one can use a number of Assemble functions to construct basic
// nodes, such as String or Int.
//
// Finally, functions like MapEntry and ListEntry allow inserting into maps and
// lists.
//
// These all use the same IPLD interfaces such as NodePrototype and
// NodeAssembler, but with some magic to reduce verbosity.
package qp

import (
Expand Down
32 changes: 0 additions & 32 deletions fluent/quip/operations.go

This file was deleted.

Loading

0 comments on commit b7347f1

Please sign in to comment.