Browse Source

preallocating memory when we can

pull/3261/head
Anton Kaliaev 5 years ago
parent
commit
3c8156a55a
No known key found for this signature in database GPG Key ID: 7B6881D965918214
5 changed files with 4 additions and 6 deletions
  1. +0
    -1
      .golangci.yml
  2. +1
    -1
      crypto/merkle/proof.go
  3. +1
    -1
      libs/common/colors.go
  4. +1
    -1
      libs/events/events.go
  5. +1
    -2
      p2p/pex/pex_reactor.go

+ 0
- 1
.golangci.yml View File

@ -25,7 +25,6 @@ linters:
- scopelint
- stylecheck
- deadcode
- prealloc
# linters-settings:
# govet:


+ 1
- 1
crypto/merkle/proof.go View File

@ -98,7 +98,7 @@ func (prt *ProofRuntime) Decode(pop ProofOp) (ProofOperator, error) {
}
func (prt *ProofRuntime) DecodeProof(proof *Proof) (ProofOperators, error) {
var poz ProofOperators
poz := make(ProofOperators, 0, len(proof.Ops))
for _, pop := range proof.Ops {
operator, err := prt.Decode(pop)
if err != nil {


+ 1
- 1
libs/common/colors.go View File

@ -43,7 +43,7 @@ func treat(s string, color string) string {
}
func treatAll(color string, args ...interface{}) string {
var parts []string
parts := make([]string, 0, len(args))
for _, arg := range args {
parts = append(parts, treat(fmt.Sprintf("%v", arg), color))
}


+ 1
- 1
libs/events/events.go View File

@ -188,7 +188,7 @@ func (cell *eventCell) RemoveListener(listenerID string) int {
func (cell *eventCell) FireEvent(data EventData) {
cell.mtx.RLock()
var eventCallbacks []EventCallback
eventCallbacks := make([]EventCallback, 0, len(cell.listeners))
for _, cb := range cell.listeners {
eventCallbacks = append(eventCallbacks, cb)
}


+ 1
- 2
p2p/pex/pex_reactor.go View File

@ -616,10 +616,9 @@ func (of oldestFirst) Less(i, j int) bool { return of[i].LastAttempt.Before(of[j
// getPeersToCrawl returns addresses of potential peers that we wish to validate.
// NOTE: The status information is ordered as described above.
func (r *PEXReactor) getPeersToCrawl() []crawlPeerInfo {
var of oldestFirst
// TODO: be more selective
addrs := r.book.ListOfKnownAddresses()
of := make(oldestFirst, 0, len(addrs))
for _, addr := range addrs {
if len(addr.ID()) == 0 {
continue // dont use peers without id


Loading…
Cancel
Save