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

Fast exit undef/empty strings in Data::Dumper::qquote() #22070

Merged
merged 3 commits into from
Jun 20, 2024

Conversation

DabeDotCom
Copy link
Contributor

This silences a squajillion (okay, five) "uninitialized" warnings, and is more efficient, anyway...

@DabeDotCom DabeDotCom force-pushed the dabedotcom/data-dumper-qquote branch from fb08490 to 1d91efe Compare March 8, 2024 22:18
@jkeenan
Copy link
Contributor

jkeenan commented Mar 8, 2024

This silences a squajillion (okay, five) "uninitialized" warnings, and is more efficient, anyway...

Can you provide an example of how you are getting these uninitialized warnings? Thanks.

@tonycoz
Copy link
Contributor

tonycoz commented Mar 11, 2024

I don't see any such warnings in the build, and Data::Dumper itself should never call qquote() with undef that I can see.

@DabeDotCom
Copy link
Contributor Author

Can you provide an example of how you are getting these uninitialized warnings? Thanks.

Sorry, I totally cheated and called it from outside... (Text::Quote mentions taking "inspiration" from Data::Dump, but I figured since Data::Dumper was a core module, I'd just leverage *it* instead.)

prompt% perl -MData::Dumper -E 'say Data::Dumper::qquote()'
Use of uninitialized value $_ in substitution (s///) at /System/Library/Perl/5.34/darwin-thread-multi-2level/Data/Dumper.pm line 764.
Use of uninitialized value in numeric gt (>) at /System/Library/Perl/5.34/darwin-thread-multi-2level/Data/Dumper.pm line 775.
Use of uninitialized value $bytes in numeric gt (>) at /System/Library/Perl/5.34/darwin-thread-multi-2level/Data/Dumper.pm line 775.
Use of uninitialized value $_ in pattern match (m//) at /System/Library/Perl/5.34/darwin-thread-multi-2level/Data/Dumper.pm line 783.
Use of uninitialized value $_ in concatenation (.) or string at /System/Library/Perl/5.34/darwin-thread-multi-2level/Data/Dumper.pm line 783.
""

Anyway, I know it's undocumented, and I'm okay if it breaks, but I figured I'd push my (trivial) optimization back upstream, just in case you were interested. «shrug»

Cheers! :-D

@demerphq
Copy link
Collaborator

demerphq commented Mar 11, 2024 via email

@tonycoz
Copy link
Contributor

tonycoz commented Mar 11, 2024

I think it could use a test or two (simple non-empty string, empty string, undef), otherwise it's good.

@jkeenan
Copy link
Contributor

jkeenan commented Jun 13, 2024

I think it could use a test or two (simple non-empty string, empty string, undef), otherwise it's good.

@DabeDotCom, could you provide some unit tests for this p.r., as per @tonycoz's request? Thanks.

@DabeDotCom DabeDotCom force-pushed the dabedotcom/data-dumper-qquote branch 3 times, most recently from c9ba999 to d9e8c70 Compare June 19, 2024 22:34
@@ -0,0 +1,80 @@
#!./perl -w
# t/seen.t - Test Seen()
Copy link
Contributor

Choose a reason for hiding this comment

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

old comment?

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good otherwise

@DabeDotCom DabeDotCom force-pushed the dabedotcom/data-dumper-qquote branch from ade6b45 to 1838c7e Compare June 19, 2024 23:09
This silences a squajillion (okay, five) "uninitialized" warnings,
and is more efficient, anyway...
(I thought that's why we didn't like Python...)
@DabeDotCom DabeDotCom force-pushed the dabedotcom/data-dumper-qquote branch from 1838c7e to 420ca2e Compare June 20, 2024 00:29
@khwilliamson khwilliamson merged commit 21017bd into Perl:blead Jun 20, 2024
29 checks passed
@demerphq
Copy link
Collaborator

demerphq commented Jun 21, 2024 via email

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.

None yet

5 participants