Skip to content

Replace multiple boolean arguments to one uint8_t. #1100

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

Merged

Conversation

zherczeg
Copy link
Member

No description provided.

@zherczeg
Copy link
Member Author

Binary size decreased by 1K.

@LaszloLango LaszloLango added enhancement An improvement binary size Affects binary size labels May 26, 2016
bool is_writable, /**< 'Writable' attribute */
bool is_enumerable, /**< 'Enumerable' attribute */
bool is_configurable) /**< 'Configurable' attribute */
uint8_t prop_attributes) /**< property attributes */
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this idea, but I'd give a name to this. What do you think about typedef uint8_t prop_attr_t; or typedef uint8_t prop_attr_flag_t;?

Copy link
Contributor

Choose a reason for hiding this comment

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

I just saw that we already have a ecma_property_flags_t, but it is an enum, so it'll be 32bit long (usually, but not always). In this case I think it is unnecessary to create a new type, but it should be mentioned in the comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

That is a flagset, not a flag. The type_and_flags in ecma_property_t is also an uint8_t. I wouldn't want to change it.

Copy link
Contributor

Choose a reason for hiding this comment

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

As I said, you don't have to change the name, just make a comment.

...
uint8_t prop_attributes) /**< property attributes (See: ecma_property_flags_t) */

@zherczeg
Copy link
Member Author

Any more thoughts?

@zherczeg zherczeg force-pushed the property_create_optimization branch from a396b0f to 73807c6 Compare May 26, 2016 12:46
@LaszloLango
Copy link
Contributor

LGTM, after the comment fixed.

the three boolean arguments of ecma_create_named_data_property and the
two boolean arguments of ecma_create_named_accessor_property are combined
into one uint8_t argument. On ARM-32 it is preferred to have less than
four arguments, since these arguments can be passed in registers.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
@zherczeg zherczeg force-pushed the property_create_optimization branch from 73807c6 to 8c92972 Compare May 30, 2016 06:55
@dbatyai
Copy link
Member

dbatyai commented May 30, 2016

LGTM

@zherczeg zherczeg merged commit 8c92972 into jerryscript-project:master May 30, 2016
@zherczeg zherczeg deleted the property_create_optimization branch May 30, 2016 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
binary size Affects binary size enhancement An improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants