[PR #325] [CLOSED] Refactor Fibonacci class to improve performance and readability #498

Closed
opened 2025-12-30 01:24:58 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/apple/pkl/pull/325
Author: @manuelsblanco
Created: 3/15/2024
Status: Closed

Base: mainHead: fibonacci


📝 Commits (1)

  • 3bd3701 Refactor 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.

## 📋 Pull Request Information **Original PR:** https://github.com/apple/pkl/pull/325 **Author:** [@manuelsblanco](https://github.com/manuelsblanco) **Created:** 3/15/2024 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fibonacci` --- ### 📝 Commits (1) - [`3bd3701`](https://github.com/apple/pkl/commit/3bd3701e617fa734a0731df58f68b1fbe08370da) Refactor Fibonacci class to improve performance and readability ### 📊 Changes **1 file changed** (+19 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `bench/src/jmh/java/org/pkl/core/Fibonacci.java` (+19 -1) </details> ### 📄 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 01:24:58 +01:00
adam closed this issue 2025-12-30 01:24:58 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#498