-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improove performace using a string builders instead of a string (#102)
Thank you very much for the improvement and congrats for your first contribution. LGTM, merging.
- Loading branch information
Showing
4 changed files
with
39 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
package faker | ||
|
||
//BinaryString is the faker struct for BinaryString | ||
import "strings" | ||
|
||
// BinaryString is the faker struct for BinaryString | ||
type BinaryString struct { | ||
faker *Faker | ||
} | ||
|
||
// BinaryString returns a random binarystring of given input length | ||
func (bn BinaryString) BinaryString(length int) string { | ||
var bs string | ||
var bs strings.Builder | ||
for i := 0; i < length; i++ { | ||
bs += bn.faker.RandomStringElement([]string{"0", "1"}) | ||
bs.WriteString(bn.faker.RandomStringElement([]string{"0", "1"})) | ||
} | ||
return bs | ||
return bs.String() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters