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

Avoid Chained Calls Directly in Function Calls #54401

Open
hawkingrei opened this issue Jul 3, 2024 · 0 comments
Open

Avoid Chained Calls Directly in Function Calls #54401

hawkingrei opened this issue Jul 3, 2024 · 0 comments
Labels
type/enhancement The issue or PR belongs to an enhancement.

Comments

@hawkingrei
Copy link
Member

Enhancement

I would like to suggest an improvement regarding the current usage of chained calls within TiDB. Currently, we have instances where chained calls are directly used within function calls. This practice causes inconvenience, especially when debugging, as it forces us to step into each of these chained calls, making the process cumbersome.

To enhance our debugging experience and code maintainability, I propose that we avoid using chained calls directly within function calls. Instead, we should break them down into intermediate variables or steps before passing them to the function. This approach would not only simplify debugging but also improve code readability.

Here is an example to illustrate the suggested change:

		// the candidate predicate should be a constant and compare predicate
		match := validCompareConstantPredicate(selection.SCtx().GetExprCtx().GetEvalCtx(), candidatePredicate)
		if match {
			result = append(result, candidatePredicate)
		}

Proposed Change:

		// the candidate predicate should be a constant and compare predicate
                ctx := selection.SCtx().GetExprCtx().GetEvalCtx()
		match := validCompareConstantPredicate(ctx, candidatePredicate)
		if match {
			result = append(result, candidatePredicate)
		}

By adopting this approach, we can set breakpoints at each intermediate step and inspect the values more easily without stepping into each chained call unintentionally.

I believe this improvement will significantly streamline our debugging process and enhance overall code quality. Your consideration and feedback on this suggestion would be greatly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

No branches or pull requests

1 participant