mirror of
https://github.com/apple/pkl.git
synced 2026-01-12 06:40:42 +01:00
[PR #325] [CLOSED] Refactor Fibonacci class to improve performance and readability #498
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/apple/pkl/pull/325
Author: @manuelsblanco
Created: 3/15/2024
Status: ❌ Closed
Base:
main← Head:fibonacci📝 Commits (1)
3bd3701Refactor Fibonacci class to improve performance and readability📊 Changes
1 file changed (+19 additions, -1 deletions)
View changed files
📝
bench/src/jmh/java/org/pkl/core/Fibonacci.java(+19 -1)📄 Description
Title: Implement Memoization for Fibonacci Calculation
Description:
This pull request introduces a significant enhancement to the Fibonacci calculation in the Fibonacci class. The previous implementation suffered from inefficiencies, especially for large values of 'n', due to redundant calculations. To address this issue, I have refactored the code to incorporate memoization, significantly improving performance and reducing computational overhead.
Memoization is achieved by introducing a new FibJavaImpl class that utilizes a HashMap to store previously computed Fibonacci numbers. This allows the function to avoid redundant calculations by retrieving previously calculated values from memory. As a result, the Fibonacci calculation becomes more efficient, particularly for large values of 'n'.
The implementation adheres to best practices in software development, enhancing readability, maintainability, and performance. It includes comprehensive documentation and explanatory comments to facilitate understanding and future modifications.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.