Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
d333dbea
Unverified
Commit
d333dbea
authored
Jun 12, 2022
by
Edward Thomson
Committed by
GitHub
Jun 12, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6288 from libgit2/cmn/mwindow-simplifications
A couple of simplications around mwindow
parents
660e6bd5
0f594445
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
10 deletions
+10
-10
src/libgit2/mwindow.c
+9
-9
src/libgit2/mwindow.h
+1
-1
No files found.
src/libgit2/mwindow.c
View file @
d333dbea
...
...
@@ -186,13 +186,16 @@ int git_mwindow_free_all(git_mwindow_file *mwf)
}
/*
* Check if a window 'win' contains the address 'offset'
* Check if a window 'win' contains both the address 'offset' and 'extra'.
*
* 'extra' is the size of the hash we're using as we always want to make sure
* that it's contained.
*/
int
git_mwindow_contains
(
git_mwindow
*
win
,
off64_t
offset
)
int
git_mwindow_contains
(
git_mwindow
*
win
,
off64_t
offset
,
off64_t
extra
)
{
off64_t
win_off
=
win
->
offset
;
return
win_off
<=
offset
&&
offset
<=
(
off64_t
)(
win_off
+
win
->
window_map
.
len
);
&&
(
offset
+
extra
)
<=
(
off64_t
)(
win_off
+
win
->
window_map
.
len
);
}
#define GIT_MWINDOW__LRU -1
...
...
@@ -237,9 +240,7 @@ static bool git_mwindow_scan_recently_used(
* store it in the output parameter. If lru_window is NULL,
* it's the first loop, so store it as well.
*/
if
(
!
lru_window
||
(
comparison_sign
==
GIT_MWINDOW__LRU
&&
lru_window
->
last_used
>
w
->
last_used
)
||
(
comparison_sign
==
GIT_MWINDOW__MRU
&&
lru_window
->
last_used
<
w
->
last_used
))
{
if
(
!
lru_window
||
(
comparison_sign
*
w
->
last_used
)
>
lru_window
->
last_used
)
{
lru_window
=
w
;
lru_last
=
w_last
;
found
=
true
;
...
...
@@ -406,14 +407,13 @@ unsigned char *git_mwindow_open(
return
NULL
;
}
if
(
!
w
||
!
(
git_mwindow_contains
(
w
,
offset
)
&&
git_mwindow_contains
(
w
,
offset
+
extra
)))
{
if
(
!
w
||
!
(
git_mwindow_contains
(
w
,
offset
,
extra
)))
{
if
(
w
)
{
w
->
inuse_cnt
--
;
}
for
(
w
=
mwf
->
windows
;
w
;
w
=
w
->
next
)
{
if
(
git_mwindow_contains
(
w
,
offset
)
&&
git_mwindow_contains
(
w
,
offset
+
extra
))
if
(
git_mwindow_contains
(
w
,
offset
,
extra
))
break
;
}
...
...
src/libgit2/mwindow.h
View file @
d333dbea
...
...
@@ -38,7 +38,7 @@ typedef struct git_mwindow_ctl {
git_vector
windowfiles
;
}
git_mwindow_ctl
;
int
git_mwindow_contains
(
git_mwindow
*
win
,
off64_t
offset
);
int
git_mwindow_contains
(
git_mwindow
*
win
,
off64_t
offset
,
off64_t
extra
);
int
git_mwindow_free_all
(
git_mwindow_file
*
mwf
);
/* locks */
unsigned
char
*
git_mwindow_open
(
git_mwindow_file
*
mwf
,
git_mwindow
**
cursor
,
off64_t
offset
,
size_t
extra
,
unsigned
int
*
left
);
int
git_mwindow_file_register
(
git_mwindow_file
*
mwf
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment