git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "SZEDER Gábor" <szeder.dev@gmail.com>
To: git@vger.kernel.org
Cc: "SZEDER Gábor" <szeder.dev@gmail.com>
Subject: [PATCH 2/2] treewide: remove unnecessary inclusions of parse-options.h from headers
Date: Sun, 19 Mar 2023 17:27:12 +0100	[thread overview]
Message-ID: <20230319162712.654137-3-szeder.dev@gmail.com> (raw)
In-Reply-To: <20230319162712.654137-1-szeder.dev@gmail.com>

The headers 'diagnose.h', 'list-objects-filter-options.h',
'ref-filter.h' and 'remote.h' declare option parsing callback
functions with a 'struct option*' parameter, and 'revision.h' declares
an option parsing helper function taking 'struct parse_opt_ctx_t*' and
'struct option*' parameters.  These headers all include
'parse-options.h', although they don't need any of the type
definitions from that header file.  Furthermore,
'list-objects-filter-options.h' and 'ref-filter.h' also define some
OPT_* macros to initialize a 'struct option', but these don't
necessitate the inclusion of parse-options.h in these headers either,
because these macros are only expanded in source files.

Remove these unnecessary inclusions of parse-options.h and use forward
declarations to declare the necessary types.

After this patch none of the header files include parse-options.h
anymore.

With these changes, the build time after modifying only
parse-options.h is reduced by about 30%, and the number of targets
built is almost 20% less:

  Before:

    $ touch parse-options.h && time make -j4 |wc -l
    353

    real    1m1.527s
    user    3m32.205s
    sys	    0m15.903s

  After:

    289

    real    0m39.285s
    user    2m12.540s
    sys     0m11.164s

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
---
 diagnose.h                    | 3 ++-
 list-objects-filter-options.h | 3 ++-
 ref-filter.h                  | 2 +-
 remote.h                      | 2 +-
 revision.h                    | 3 ++-
 5 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/diagnose.h b/diagnose.h
index 7a4951a786..f525219ab0 100644
--- a/diagnose.h
+++ b/diagnose.h
@@ -2,7 +2,8 @@
 #define DIAGNOSE_H
 
 #include "strbuf.h"
-#include "parse-options.h"
+
+struct option;
 
 enum diagnose_mode {
 	DIAGNOSE_NONE,
diff --git a/list-objects-filter-options.h b/list-objects-filter-options.h
index ef03b45132..727c986122 100644
--- a/list-objects-filter-options.h
+++ b/list-objects-filter-options.h
@@ -2,10 +2,11 @@
 #define LIST_OBJECTS_FILTER_OPTIONS_H
 
 #include "object.h"
-#include "parse-options.h"
 #include "string-list.h"
 #include "strbuf.h"
 
+struct option;
+
 /*
  * The list of defined filters for list-objects.
  */
diff --git a/ref-filter.h b/ref-filter.h
index aa0eea4ecf..daa6d02017 100644
--- a/ref-filter.h
+++ b/ref-filter.h
@@ -4,7 +4,6 @@
 #include "oid-array.h"
 #include "refs.h"
 #include "commit.h"
-#include "parse-options.h"
 
 /* Quoting styles */
 #define QUOTE_NONE 0
@@ -24,6 +23,7 @@
 
 struct atom_value;
 struct ref_sorting;
+struct option;
 
 enum ref_sorting_order {
 	REF_SORTING_REVERSE = 1<<0,
diff --git a/remote.h b/remote.h
index 5b38ee20b8..73638cefeb 100644
--- a/remote.h
+++ b/remote.h
@@ -1,10 +1,10 @@
 #ifndef REMOTE_H
 #define REMOTE_H
 
-#include "parse-options.h"
 #include "hashmap.h"
 #include "refspec.h"
 
+struct option;
 struct transport_ls_refs_options;
 
 /**
diff --git a/revision.h b/revision.h
index ab71443696..649f817f39 100644
--- a/revision.h
+++ b/revision.h
@@ -2,7 +2,6 @@
 #define REVISION_H
 
 #include "commit.h"
-#include "parse-options.h"
 #include "grep.h"
 #include "notes.h"
 #include "pretty.h"
@@ -62,6 +61,8 @@ struct string_list;
 struct saved_parents;
 struct bloom_key;
 struct bloom_filter_settings;
+struct option;
+struct parse_opt_ctx_t;
 define_shared_commit_slab(revision_sources, char *);
 
 struct rev_cmdline_info {
-- 
2.40.0.499.g88fa0b00d2


  parent reply	other threads:[~2023-03-19 16:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-19 16:27 [PATCH 0/2] Remove unnecessary inclusions of parse-options.h from headers SZEDER Gábor
2023-03-19 16:27 ` [PATCH 1/2] treewide: include parse-options.h in source files SZEDER Gábor
2023-03-19 16:27 ` SZEDER Gábor [this message]
2023-03-20 16:41 ` [PATCH 0/2] Remove unnecessary inclusions of parse-options.h from headers Elijah Newren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230319162712.654137-3-szeder.dev@gmail.com \
    --to=szeder.dev@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).