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

Extract subtitles to a constant to reduce allocations #11056

Merged

Conversation

krzysiek1507
Copy link
Contributor

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Subtitles don't change so we can move them to a constant and save some memory (if you need stats I can provide them) because this hash and strings are created every time title_with_timeframe is called (which is 3 times on https://github.com/forem/forem/blob/467e99556cf1fc088bbd91ec0612d4a64ff91ffd/app/views/articles/index.html.erb).

This PR reduces the number of creations of this hash from 3 * number of calls of render "articles/index" to 1. (Similar on tags/_meta).

Related Tickets & Documents

QA Instructions, Screenshots, Recordings

Check if the title contains values from the hash.

Added tests?

  • yes
  • no, because they aren't needed
  • no, because I need help

Added to documentation?

  • docs.forem.com
  • readme
  • no documentation needed

@pr-triage pr-triage bot added the PR: unreviewed bot applied label for PR's with no review label Oct 24, 2020
Copy link
Contributor

@citizen428 citizen428 left a comment

Choose a reason for hiding this comment

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

Nice first contribution, thanks @krzysiek1507 👏

@pr-triage pr-triage bot added PR: partially-approved bot applied label for PR's where a single reviewer approves changes and removed PR: unreviewed bot applied label for PR's with no review labels Oct 26, 2020
Copy link
Contributor

@rhymes rhymes left a comment

Choose a reason for hiding this comment

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

Love it, thanks!

@pr-triage pr-triage bot added PR: reviewed-approved bot applied label for PR's where reviewer approves changes and removed PR: partially-approved bot applied label for PR's where a single reviewer approves changes labels Oct 26, 2020
@rhymes rhymes merged commit 2078490 into forem:master Oct 26, 2020
@pr-triage pr-triage bot added PR: merged bot applied label for PR's that are merged and removed PR: reviewed-approved bot applied label for PR's where reviewer approves changes labels Oct 26, 2020
@krzysiek1507 krzysiek1507 deleted the refactor/extract-subtitle-constant branch October 26, 2020 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: merged bot applied label for PR's that are merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants