You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "xiaoxiang781216 (via GitHub)" <gi...@apache.org> on 2023/03/02 14:24:47 UTC

[GitHub] [nuttx-apps] xiaoxiang781216 commented on a diff in pull request #1610: nsh: Improve performance of `help` by line buffer

xiaoxiang781216 commented on code in PR #1610:
URL: https://github.com/apache/nuttx-apps/pull/1610#discussion_r1123176932


##########
nshlib/nsh_command.c:
##########
@@ -650,22 +652,32 @@ static inline void help_cmdlist(FAR struct nsh_vtbl_s *vtbl)
 
   for (i = 0; i < ncmdrows; i++)
     {
-      nsh_output(vtbl, "  ");
+      /* Tab before a new line */
+
+      offset = 4;
+      memset(line, ' ', offset);
+
       for (j = 0, k = i;
            j < cmdsperline && k < NUM_CMDS;
            j++, k += ncmdrows)
         {
-          nsh_output(vtbl, "%s", g_cmdmap[k].cmd);
+          /* Copy the cmd name to line buffer */
+
+          offset += strlcpy(line + offset, g_cmdmap[k].cmd,
+                    sizeof(line) - offset);

Review Comment:
   ```suggestion
                              sizeof(line) - offset);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org