Project

General

Profile

Actions

Misc #14798

closed

[PATCH] gc.c: reduce parameters for gc_start and garbage_collect

Added by normalperson (Eric Wong) over 6 years ago. Updated over 6 years ago.

Status:
Closed
Assignee:
-
[ruby-core:87311]

Description

Every time I look at gc.c, I get confused by argument ordering:

	gc_start(..., TRUE, TRUE, FALSE, ...)
	gc_start(..., FALSE, FALSE, FALSE, ... )

While we do not have kwargs in C, we can use flags to improve readability:

	gc_start(...,
		GPR_FLAG_FULL_MARK | GPR_FLAG_IMMEDIATE_MARK |
		GPR_FLAG_IMMEDIATE_SWEEP | ...)

It's a little more verbose, but maybe "_FLAG" is unnecessary, even.

Full diff:

   https://80x24.org/spew/20180530224643.21110-1-e@80x24.org/raw

Broken out patches:

   https://80x24.org/spew/20180530224643.21110-2-e@80x24.org/raw
   https://80x24.org/spew/20180530224643.21110-3-e@80x24.org/raw
   https://80x24.org/spew/20180530224643.21110-4-e@80x24.org/raw

Or pull request:

    The following changes since commit b9212a7771a5e67f3b48bbf4c76cd087a8d87e49:

      Ignore bundler assertions on ruby core test suite. (2018-05-30 13:03:47 +0000)

    are available in the Git repository at:

      git://80x24.org/ruby gc-params

    for you to fetch changes up to d343b643df5d670548f545dfe1f14e3f8e5f4738:

      gc.c: introduce GPR_FLAG_FULL_MARK to reduce parameters (2018-05-30 22:47:14 +0000)

    ----------------------------------------------------------------
    Eric Wong (3):
	  gc.c: reduce boolean parameters for gc_start / garbage_collect
	  gc.c: introduce GPR_FLAG_IMMEDIATE_MARK to reduce parameters
	  gc.c: introduce GPR_FLAG_FULL_MARK to reduce parameters

     gc.c | 78 +++++++++++++++++++++++++++++++++++++++++---------------------------
     1 file changed, 47 insertions(+), 31 deletions(-)

Files

gc.c-reduce-function-parameters.patch (8.15 KB) gc.c-reduce-function-parameters.patch normalperson (Eric Wong), 05/30/2018 11:01 PM
Actions #1

Updated by normalperson (Eric Wong) over 6 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r63575.


gc.c: reduce parameters for gc_start and garbage_collect

Every time I look at gc.c, I get confused by argument ordering:

gc_start(..., TRUE, TRUE, FALSE, ...)
gc_start(..., FALSE, FALSE, FALSE, ... )

While we do not have kwargs in C, we can use flags to improve readability:

gc_start(...,
	GPR_FLAG_FULL_MARK | GPR_FLAG_IMMEDIATE_MARK |
	GPR_FLAG_IMMEDIATE_SWEEP | ...)

[ruby-core:87311] [Misc #14798]

Updated by normalperson (Eric Wong) over 6 years ago

Same idea for sleep_forever (and sleep_timespec) in thread.c:

https://80x24.org/spew/20180608093951.21762-1-e@80x24.org/raw

Actions

Also available in: Atom PDF

Like0
Like0Like0