Skip to content

Commit

Permalink
Remove early-loading for contest questions
Browse files Browse the repository at this point in the history
  • Loading branch information
j178 committed Jan 30, 2023
1 parent 87757ef commit 5706be4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
2 changes: 2 additions & 0 deletions leetcode/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ func (c *cnClient) parseContestHtml(html []byte, questionSlug string) (*Question

// 每次 "运行代码" 会产生两个 submission, 一个是运行我们的代码,一个是运行标程。

// RunCode runs code on leetcode server. Questions no need to be fully loaded.
func (c *cnClient) RunCode(q *QuestionData, lang string, code string, dataInput string) (
*InterpretSolutionResult,
error,
Expand Down Expand Up @@ -688,6 +689,7 @@ func (c *cnClient) RunCode(q *QuestionData, lang string, code string, dataInput
return &resp, err
}

// SubmitCode submits code to leetcode server. Questions no need to be fully loaded.
func (c *cnClient) SubmitCode(q *QuestionData, lang string, code string) (string, error) {
url := ""
if q.IsContest() {
Expand Down
9 changes: 0 additions & 9 deletions leetcode/contest.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package leetcode
import (
"errors"
"time"

"github.com/hashicorp/go-hclog"
)

var ErrContestNotStarted = errors.New("contest has not started")
Expand Down Expand Up @@ -76,7 +74,6 @@ func (ct *Contest) GetQuestionByNumber(num int) (*QuestionData, error) {
}

q := ct.Questions[num-1]
err = q.Fulfill()
return q, err
}

Expand All @@ -85,12 +82,6 @@ func (ct *Contest) GetAllQuestions() ([]*QuestionData, error) {
if err != nil {
return nil, err
}
for _, q := range ct.Questions {
err = q.Fulfill()
if err != nil {
hclog.L().Error("load contest question failed", "title", q.Title, "err", err)
}
}
return ct.Questions, nil
}

Expand Down

0 comments on commit 5706be4

Please sign in to comment.