mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
Welcome: Replace rand()/srand() with AK::get_random_uniform()
This commit is contained in:
parent
02121336b4
commit
902d24136b
Notes:
sideshowbarker
2024-07-18 04:55:16 +09:00
Author: https://github.com/thankyouverycool Commit: https://github.com/SerenityOS/serenity/commit/902d24136b3 Pull-request: https://github.com/SerenityOS/serenity/pull/9736
1 changed files with 3 additions and 8 deletions
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include "WelcomeWidget.h"
|
||||
#include <AK/Random.h>
|
||||
#include <Applications/Welcome/WelcomeWindowGML.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Process.h>
|
||||
|
@ -17,7 +18,6 @@
|
|||
#include <LibMarkdown/Document.h>
|
||||
#include <LibWeb/OutOfProcessWebView.h>
|
||||
#include <serenity.h>
|
||||
#include <time.h>
|
||||
|
||||
WelcomeWidget::WelcomeWidget()
|
||||
{
|
||||
|
@ -68,7 +68,6 @@ WelcomeWidget::WelcomeWidget()
|
|||
|
||||
open_and_parse_readme_file();
|
||||
open_and_parse_tips_file();
|
||||
srand(time(nullptr));
|
||||
set_random_tip();
|
||||
}
|
||||
|
||||
|
@ -116,12 +115,8 @@ void WelcomeWidget::set_random_tip()
|
|||
if (m_tips.is_empty())
|
||||
return;
|
||||
|
||||
size_t n;
|
||||
do
|
||||
n = rand();
|
||||
while (n >= m_tips.size());
|
||||
m_initial_tip_index = n;
|
||||
m_tip_label->set_text(m_tips[n]);
|
||||
m_initial_tip_index = get_random_uniform(m_tips.size());
|
||||
m_tip_label->set_text(m_tips[m_initial_tip_index]);
|
||||
}
|
||||
|
||||
void WelcomeWidget::paint_event(GUI::PaintEvent& event)
|
||||
|
|
Loading…
Reference in a new issue