6 Commits
v1.1.1 ... main

Author SHA1 Message Date
github-actions[bot]
d1148580df chore(main): release 1.1.2 (#12)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-10-21 01:59:58 +01:00
c3c5f71c7a docs(readme): fix build badge 2024-10-21 01:57:46 +01:00
2e276c037b docs(readme): fix styling of badges 2024-10-21 01:53:54 +01:00
af31c21ec1 Merge pull request #11 from jimeh/perf-improvement
fix(perf): minor improvement when no indent is found
2024-10-21 01:50:25 +01:00
84715b90d0 fix(perf): minor improvement when no indent is found 2024-10-21 01:43:49 +01:00
3878874bbe chore: remove bootstrap values in release-please config 2022-12-05 01:24:42 +00:00
5 changed files with 22 additions and 29 deletions

View File

@@ -1,3 +1,3 @@
{
".": "1.1.1"
".": "1.1.2"
}

View File

@@ -1,5 +1,12 @@
# Changelog
## [1.1.2](https://github.com/jimeh/undent/compare/v1.1.1...v1.1.2) (2024-10-21)
### Bug Fixes
* **perf:** minor improvement when no indent is found ([84715b9](https://github.com/jimeh/undent/commit/84715b90d000292e4e4fbe081e00a583acf0dada))
## [1.1.1](https://github.com/jimeh/undent/compare/v1.1.0...v1.1.1) (2022-12-05)

View File

@@ -9,29 +9,13 @@
</p>
<p align="center">
<a href="https://pkg.go.dev/github.com/jimeh/undent">
<img src="https://img.shields.io/badge/%E2%80%8B-reference-387b97.svg?logo=go&logoColor=white"
alt="Go Reference">
</a>
<a href="https://github.com/jimeh/undent/releases">
<img src="https://img.shields.io/github/v/tag/jimeh/undent?label=release" alt="GitHub tag (latest SemVer)">
</a>
<a href="https://github.com/jimeh/undent/actions">
<img src="https://img.shields.io/github/workflow/status/jimeh/undent/CI.svg?logo=github" alt="Actions Status">
</a>
<a href="https://codeclimate.com/github/jimeh/undent">
<img src="https://img.shields.io/codeclimate/coverage/jimeh/undent.svg?logo=code%20climate" alt="Coverage">
</a>
<a href="https://github.com/jimeh/undent/issues">
<img src="https://img.shields.io/github/issues-raw/jimeh/undent.svg?style=flat&logo=github&logoColor=white"
alt="GitHub issues">
</a>
<a href="https://github.com/jimeh/undent/pulls">
<img src="https://img.shields.io/github/issues-pr-raw/jimeh/undent.svg?style=flat&logo=github&logoColor=white" alt="GitHub pull requests">
</a>
<a href="https://github.com/jimeh/undent/blob/main/LICENSE">
<img src="https://img.shields.io/github/license/jimeh/undent.svg?style=flat" alt="License Status">
</a>
<a href="https://pkg.go.dev/github.com/jimeh/undent"><img src="https://img.shields.io/badge/%E2%80%8B-reference-387b97.svg?logo=go&logoColor=white" alt="Go Reference"></a>
<a href="https://github.com/jimeh/undent/releases"><img src="https://img.shields.io/github/v/tag/jimeh/undent?label=release" alt="GitHub tag (latest SemVer)"></a>
<a href="https://github.com/jimeh/undent/actions"><img src="https://img.shields.io/github/actions/workflow/status/jimeh/undent/ci.yml?logo=github" alt="Actions Status"></a>
<a href="https://codeclimate.com/github/jimeh/undent"><img src="https://img.shields.io/codeclimate/coverage/jimeh/undent.svg?logo=code%20climate" alt="Coverage"></a>
<a href="https://github.com/jimeh/undent/issues"><img src="https://img.shields.io/github/issues-raw/jimeh/undent.svg?style=flat&logo=github&logoColor=white" alt="GitHub issues"></a>
<a href="https://github.com/jimeh/undent/pulls"><img src="https://img.shields.io/github/issues-pr-raw/jimeh/undent.svg?style=flat&logo=github&logoColor=white" alt="GitHub pull requests"></a>
<a href="https://github.com/jimeh/undent/blob/main/LICENSE"><img src="https://img.shields.io/github/license/jimeh/undent.svg?style=flat" alt="License Status"></a>
</p>
```go

View File

@@ -1,6 +1,4 @@
{
"bootstrap-sha": "369ec87dddfae22534693f8cf3be6cb85bc46f9d",
"last-release-sha": "369ec87dddfae22534693f8cf3be6cb85bc46f9d",
"release-type": "go",
"bump-minor-pre-major": true,
"bump-patch-for-minor-pre-major": true,

View File

@@ -22,7 +22,7 @@ func Bytes(s string) []byte {
}
// find smallest indent relative to each line-feed
min := 99999999999
min := -1
count := 0
lfs := make([]int, 0, strings.Count(s, "\n"))
@@ -35,7 +35,7 @@ func Bytes(s string) []byte {
if s[i] == lf {
lfs = append(lfs, i)
indent = 0
} else if indent < min {
} else if indent < min || min == -1 {
switch s[i] {
case spc, tab:
indent++
@@ -43,13 +43,17 @@ func Bytes(s string) []byte {
if indent > 0 {
count++
}
if indent < min {
if indent < min || min == -1 {
min = indent
}
}
}
}
if min == -1 {
return []byte(s)
}
// extract each line without indentation
out := make([]byte, 0, len(s)-(min*count))