Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimizations by pbfy0 (Rebase, needs testing) #255

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

gameblabla
Copy link

Given that pby0 has since passed away, i did a rebase of his branch.
The old PR could be found here :
#123

My branch compiles but i wasn't able to try it on real hardware given that i have since sold my TI Nspire...
Also, i wasn't able to keep the authorship of the commits, given that it required several changes and all and i don't know how to do that... Oh well.

Made a comment here (#123 (comment)) but it would be a waste to not merge back his work so there we go.

static const t_key KEY_NSPIRE_DOC = KEYTPAD_(_KEY_DUMMY_ROW, _KEY_DUMMY_COL, 0x1C, 0x008);
static const t_key KEY_NSPIRE_TRIG = KEYTPAD_(_KEY_DUMMY_ROW, _KEY_DUMMY_COL, 0x12, 0x200);
static const t_key KEY_NSPIRE_SCRATCHPAD = KEYTPAD_(_KEY_DUMMY_ROW, _KEY_DUMMY_COL, 0x1A, 0x400);
extern const t_key KEY_NSPIRE_RET;
Copy link
Contributor

Choose a reason for hiding this comment

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

This means that every use of any of these variables will also pull in all others via keys.o. Can you compare the impact?

Copy link
Author

Choose a reason for hiding this comment

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

Obviously this is a mistake on my part... Let me fix that.

Copy link
Author

Choose a reason for hiding this comment

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

Actually i fixed it in gameblabla@7353060 since it wouldn't build ofc but perhaps i should redo my patches and force push ?

Copy link
Contributor

Choose a reason for hiding this comment

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

You can force push at any time - GH reviews work well with that.

@gameblabla
Copy link
Author

Alright so i cleaned up my commits and i also recompiled it just in case to make sure it does compile fine.
Now all it needs is some testing to make sure it's all working fine. (because as i said earlier, i don't have the hardware anymore :/)

@gameblabla
Copy link
Author

gameblabla commented Nov 20, 2020

Compiled a newer build of Picodrive with those changes and gave it to someone else to try. It worked fine, no harmful effects. (although he did not use my newer resources file)

gameblabla added 4 commits December 3, 2020 18:01
This avoids having several copies of the table.
(Seems to only happened when compiled with -O0 however)

Original commit was made by pbfy0 :
ndless-nspire@5ea35e9
As a result, ndless will write the location it has found the associated program to ndless.cfg.
This significantly speeds opening programs with association, since it avoids trawling through the entire filesystem each time.

This is a rebase based upon ndless-nspire@b4ea94c
Copy link
Contributor

@adriweb adriweb left a comment

Choose a reason for hiding this comment

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

(oops)

Copy link
Contributor

@adriweb adriweb left a comment

Choose a reason for hiding this comment

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

I may be wrong, but the "Support absolute paths in ndless.cfg." commit seems to me like it would make it possible to execute programs stored in /documents while we're in PTT (i.e. with /documents not being accessible). So, I guess we shouldn't have this patch for obvious cheating-enabling reasons (what's another usecase for that anyway?)

@gameblabla
Copy link
Author

I got my TI Nspire CX II today and i can confirm that as of my latest push, it works fine on my calc. I did compile everything with GCC 10.2 instead of GCC 10.1 but that's something you can address later on.

I may be wrong, but the "Support absolute paths in ndless.cfg." commit seems to me like it would make it possible to execute programs stored in /documents while we're in PTT (i.e. with /documents not being accessible). So, I guess we shouldn't have this patch for obvious cheating-enabling reasons (what's another usecase for that anyway?)

Had an issue with PTT mode where i couldn't get out unless i used ndless on it (i didn't have a Windows machine on hand either) so this was useful to me. Not sure though if the commit does fix it (it was not mine) and i don't want to try it either due to the issue i just mentioned : )

@adriweb
Copy link
Contributor

adriweb commented Dec 3, 2020 via email

@admsev
Copy link

admsev commented May 27, 2024

@gooroodev WDYT?

@gooroodev
Copy link

@admsev, thanks for the invite!

1. Summary of Changes

The pull request includes the following changes:

  1. Refactoring of Key Definitions:

    • Moved the static key definitions from keys.h to a new file keys.c.
    • Changed the key definitions in keys.h to extern declarations.
  2. Configuration Management Enhancements:

    • Introduced a new struct cfg_entry to encapsulate key-value pairs.
    • Added functions to manage configuration entries:
      • cfg_get_entry
      • cfg_set_value
      • cfg_put
      • cfg_put_fileext
    • Enhanced the existing configuration functions to support comments and dynamic resizing of the configuration entries array.
    • Added a function cfg_save_file to save the configuration back to a file.
  3. File Association Improvements:

    • Modified ld_exec_with_args to use the new configuration functions for file associations.
    • Improved handling of absolute paths and automatic updating of configuration entries.

2. Issues, Bugs, or Typos

Issue 1: Redundant Declaration

  • The function const char *cfg_get(const char *key); is declared twice in libndls.h.

Proposed Fix:
Remove the redundant declaration.

diff --git a/ndless-sdk/include/libndls.h b/ndless-sdk/include/libndls.h
index 8bede8c5..9d876ef3 100644
--- a/ndless-sdk/include/libndls.h
+++ b/ndless-sdk/include/libndls.h
@@ -109,7 +109,6 @@ void cfg_set_value(struct cfg_entry *entr, const char *val);
 const char *cfg_get(const char *key);
 struct cfg_entry *cfg_put(const char *key, const char *val);
 void cfg_put_fileext(const char *ext, const char *prgm);
-const char *cfg_get(const char *key);
 void cfg_register_fileext(const char *ext, const char *prgm);
 void cfg_register_fileext_file(const char *fielpath, const char *ext, const char *prgm);
 #define nl_hassyscall(x) _nl_hassyscall(e_##x)

Issue 2: Typo in Function Name

  • The function cfg_register_fileext_file has a typo in the parameter name fielpath.

Proposed Fix:
Correct the parameter name to filepath.

diff --git a/ndless-sdk/include/libndls.h b/ndless-sdk/include/libndls.h
index 8bede8c5..9d876ef3 100644
--- a/ndless-sdk/include/libndls.h
+++ b/ndless-sdk/include/libndls.h
@@ -111,7 +111,7 @@ void cfg_put_fileext(const char *ext, const char *prgm);
 const char *cfg_get(const char *key);
 void cfg_register_fileext(const char *ext, const char *prgm);
 void cfg_register_fileext_file(const char *fielpath, const char *ext, const char *prgm);
-void cfg_register_fileext_file(const char *fielpath, const char *ext, const char *prgm);
+void cfg_register_fileext_file(const char *filepath, const char *ext, const char *prgm);
 #define nl_hassyscall(x) _nl_hassyscall(e_##x)
 #define nl_hassyscall(x) _nl_hassyscall(e_##x)

3. General Review of Code Quality and Style

Code Quality:

  • Modularity: The refactoring of key definitions into a separate keys.c file improves modularity.
  • Memory Management: The use of dynamic memory allocation and reallocation for configuration entries is handled well, ensuring efficient memory usage.
  • Error Handling: Adequate error handling is present, particularly in file operations and memory allocations.
  • Documentation: The code lacks inline comments explaining the purpose and functionality of complex sections, which would aid in readability and maintenance.

Code Style:

  • Consistency: The code follows a consistent style in terms of indentation, naming conventions, and braces placement.
  • Clarity: Variable and function names are descriptive, making the code relatively easy to understand.
  • Redundancy: There is some redundancy in function declarations and parameter names, as mentioned in the issues section.

Conclusion

Overall, the pull request introduces significant improvements and optimizations to the codebase. Addressing the identified issues and adding inline comments would further enhance the code quality and maintainability.

Yours, Gooroo.dev. I'd love to hear from you! React or reply.

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.

5 participants