Skip to content

fix: ExpTaylor race condition#414

Open
Streppel wants to merge 1 commit intoshopspring:masterfrom
Streppel:fix/expTaylor-race-condition
Open

fix: ExpTaylor race condition#414
Streppel wants to merge 1 commit intoshopspring:masterfrom
Streppel:fix/expTaylor-race-condition

Conversation

@Streppel
Copy link
Copy Markdown

Related: #368

Adds a RWMutex around the shared factorials slice.

Copy link
Copy Markdown

@8xmx8 8xmx8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each call is computed independently; while it may be slightly slower, it is safer and clearer.

func (d Decimal) ExpTaylor(precision int32) (Decimal, error) {
	var factorials = []Decimal{New(1, 0)}
	// Note(mwoss): Implementation can be optimized by exclusively using big.Int API only
	if d.IsZero() {
		return Decimal{oneInt, 0}.Round(precision), nil
	}
···

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants