Skip to content

Commit dae5ef8

Browse files
committed
Improve README
1 parent 0e6fb1f commit dae5ef8

File tree

2 files changed

+7
-147
lines changed

2 files changed

+7
-147
lines changed

README.md

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
1+
[![Build Status](https://travis-ci.org/JohnCGriffin/overflow.png)](https://travis-ci.org/JohnCGriffin/overflow)
12
# overflow
23
Check for integer overflow in Golang arithmetic and type conversion.
34

4-
Other language README: [中文版](./README.zh_CN.md)
55
### Install
66

7-
*This is a special README before the PR is merged by the upstream.*
8-
9-
This repository forks from `johncgriffin/overflow` and adds overflow detection for unsigned integer arithmetic and type conversions between integers.
10-
11-
It has been well tested and benchmarked, and passed the code security scan provided by Github Workflow.
12-
13-
[![CodeQL](https://github.com/rwxe/overflow/actions/workflows/codeql.yml/badge.svg)](https://github.com/rwxe/overflow/actions/workflows/codeql.yml)
14-
157
```sh
16-
go get github.com/rwxe/overflow
8+
go get github.com/johncgriffin/overflow
179
```
1810

1911
In order to be compatible with the old code and keep the code simple and readable, the new code still does not use generics, but uses templates to generate code. So the majority of repetitive code is generated by `overflow_template.sh`.
@@ -26,7 +18,7 @@ go generate
2618

2719
#### Arithmetic overflow detection
2820
```go
29-
import "github.com/rwxe/overflow"
21+
import "github.com/JohnCGriffin/overflow"
3022

3123
func main() {
3224
addend := math.MaxInt64 - 5
@@ -115,13 +107,15 @@ There's a good case to be made that a panic is an unidiomatic but proper respons
115107

116108
### Performance considerations
117109

118-
Compared with the integer type safety libraries of other languages (such as C++), this library uses some seemingly slow operations, such as division. But this does not mean that these methods will be slow, on the contrary, it will be faster than complex implementations in other languages. The reason is that Go does not allow forced inlining, and any complex functions will be abandoned for inlining, resulting in additional calling overhead. Short functions are lightning fast due to automatic inlining. For example, for unsigned 64-bit integer multiplication overflow detection, when inlining is disabled, division takes five times as long as long multiplication, but after automatic inlining is allowed, division takes 1/5 of long multiplication.
110+
Compared to integer safe libraries in other languages (e.g. C++), this library uses some seemingly slow operations, such as division. But that doesn't mean these methods will be slow. In fact, because of Go's automatic inlining strategy for short functions and compiler optimizations, these operations are actually very fast in benchmark tests, lightning fast.
111+
112+
In addition, Go defines the overflow behavior of signed integers, making the detection of signed integer overflow simple and efficient.
119113

120114
Note that using `//go:noinline` in your business function will not affect the inlining of the library function. Only disabling global inlining through `-gcflags="-l"` will affect the inlining of this library function.
121115

122116
### Basis and dependencies
123117

124-
This library is based on Go's official compiler implementation and language specification, which defines the behavior when integer overflow occurs.
118+
The library is developed based on Go's official compiler implementation (gc) and language specifications.
125119

126120
### License
127121

README.zh_CN.md

Lines changed: 0 additions & 134 deletions
This file was deleted.

0 commit comments

Comments
 (0)