mirror of
https://github.com/gonum/gonum.git
synced 2025-10-29 01:33:14 +08:00
num: replace bytes.Buffer with strings.Builder for format construction
This commit is contained in:
@@ -5,9 +5,9 @@
|
||||
package dual
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Number is a float64 precision dual number.
|
||||
@@ -52,9 +52,7 @@ func (d Number) Format(fs fmt.State, c rune) {
|
||||
|
||||
// This is horrible, but it's what we have.
|
||||
func fmtString(fs fmt.State, c rune, prec, width int, wantPlus bool) string {
|
||||
// TODO(kortschak) Replace this with strings.Builder
|
||||
// when go1.9 support is dropped from Gonum.
|
||||
var b bytes.Buffer
|
||||
var b strings.Builder
|
||||
b.WriteByte('%')
|
||||
for _, f := range "0+- " {
|
||||
if fs.Flag(int(f)) || (f == '+' && wantPlus) {
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
package dualquat
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"gonum.org/v1/gonum/num/dual"
|
||||
"gonum.org/v1/gonum/num/quat"
|
||||
@@ -59,9 +59,7 @@ func (d Number) Format(fs fmt.State, c rune) {
|
||||
|
||||
// This is horrible, but it's what we have.
|
||||
func fmtString(fs fmt.State, c rune, prec, width int, wantPlus bool) string {
|
||||
// TODO(kortschak) Replace this with strings.Builder
|
||||
// when go1.9 support is dropped from Gonum.
|
||||
var b bytes.Buffer
|
||||
var b strings.Builder
|
||||
b.WriteByte('%')
|
||||
for _, f := range "0+- " {
|
||||
if fs.Flag(int(f)) || (f == '+' && wantPlus) {
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
package hyperdual
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Number is a float64 precision hyperdual number.
|
||||
@@ -55,9 +55,7 @@ func (d Number) Format(fs fmt.State, c rune) {
|
||||
|
||||
// This is horrible, but it's what we have.
|
||||
func fmtString(fs fmt.State, c rune, prec, width int, wantPlus bool) string {
|
||||
// TODO(kortschak) Replace this with strings.Builder
|
||||
// when go1.9 support is dropped from Gonum.
|
||||
var b bytes.Buffer
|
||||
var b strings.Builder
|
||||
b.WriteByte('%')
|
||||
for _, f := range "0+- " {
|
||||
if fs.Flag(int(f)) || (f == '+' && wantPlus) {
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
package quat
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -53,9 +52,7 @@ func (q Number) Format(fs fmt.State, c rune) {
|
||||
|
||||
// This is horrible, but it's what we have.
|
||||
func fmtString(fs fmt.State, c rune, prec, width int, wantPlus bool) string {
|
||||
// TODO(kortschak) Replace this with strings.Builder
|
||||
// when go1.9 support is dropped from Gonum.
|
||||
var b bytes.Buffer
|
||||
var b strings.Builder
|
||||
b.WriteByte('%')
|
||||
for _, f := range "0+- " {
|
||||
if fs.Flag(int(f)) || (f == '+' && wantPlus) {
|
||||
|
||||
Reference in New Issue
Block a user