[PR #111] [MERGED] Simplify sha1 functions #115

Closed
opened 2026-02-16 10:24:09 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-gitea/git/pull/111
Author: @ethantkoenig
Created: 2/10/2018
Status: Merged
Merged: 2/10/2018
Merged by: @lafriks

Base: masterHead: simplify/sha1


📝 Commits (1)

📊 Changes

1 file changed (+5 additions, -24 deletions)

View changed files

📝 sha1.go (+5 -24)

📄 Description

Some simplifications to prevent wheel re-invention:

  • Use hex.EncodeString(..) instead of manually hex encoding
    • This is likely to be faster, since we don't have to allocate a byte array containg 012..ef each call.
  • Use copy(..) instead of manually copying bytes
    • This is likely to be faster, since copy has architecture-specialized implementations
  • Use bytes.Equal(..) instead of manually comparing bytes
    • Again, this is likely to be faster, since bytes.Equal has architecture-specialized implementations

For the record, converting an array to a slice (arr[:]) does not copy the array.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-gitea/git/pull/111 **Author:** [@ethantkoenig](https://github.com/ethantkoenig) **Created:** 2/10/2018 **Status:** ✅ Merged **Merged:** 2/10/2018 **Merged by:** [@lafriks](https://github.com/lafriks) **Base:** `master` ← **Head:** `simplify/sha1` --- ### 📝 Commits (1) - [`06d9ca6`](https://github.com/go-gitea/git/commit/06d9ca6b7290b719023a8fc88a63531426389c6d) Simplify sha1 functions ### 📊 Changes **1 file changed** (+5 additions, -24 deletions) <details> <summary>View changed files</summary> 📝 `sha1.go` (+5 -24) </details> ### 📄 Description Some simplifications to prevent wheel re-invention: - Use `hex.EncodeString(..)` instead of manually hex encoding - This is likely to be faster, since we don't have to allocate a byte array containg `012..ef` each call. - Use `copy(..)` instead of manually copying bytes - This is likely to be faster, since `copy` has architecture-specialized implementations - Use `bytes.Equal(..)` instead of manually comparing bytes - Again, this is likely to be faster, since `bytes.Equal` has architecture-specialized implementations For the record, converting an array to a slice (`arr[:]`) does *not* copy the array. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 10:24:09 -05:00
yindo closed this issue 2026-02-16 10:24:09 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: go-gitea/git#115