Mailinglist Archive: zypp-devel (56 mails)
| < Previous | Next > |
[zypp-devel] Re: [zypp-commit] r8127 - in /branches/tmp/ma/jump_sat/libzypp/zypp: ./ base/ parser/susetags/ pool/ sat/ sat/detail/
- From: Michael Matz <matz@xxxxxxx>
- Date: Tue, 18 Dec 2007 23:40:39 +0100 (CET)
- Message-id: <Pine.LNX.4.64.0712182235120.23011@xxxxxxxxxxxxx>
Hi,
On Tue, 18 Dec 2007, mlandres@xxxxxxxxxxxxxxxx wrote:
I think it would be better if either libzypp would do away with the
Solvable kind altogether, or implement this so that it doesn't take up any
space in the libzypp wrapper of the sat Solvable structure.
I can't really see how fantastically usefull the kind is to deserve it
having an own member. The only uses I can imagine are of the type "give
me only Patches" or "don't search Patterns" and the like. The old solver
also uses them in Dependencies, but let's ignore that, as it's going away.
So, in all cases you already have a Solvable, hence the complete SAT Name,
which includes the "type". I think it would be better to compute the kind
from that whenever it's necessary, instead of storing it. It can be done
quite fast when we assume that ':' doesn't occur normally in a name (we
can assume that):
int solv2kind (Solvable *s)
{
if (s->arch == ARCH_SRC || s->arch == ARCH_NOSRC)
return KIND_SOURCEPACK;
const char *name = id2str(s->name);
// make sure we have four characters
if (!(name[0] && name[1] && name[2] && name[3]))
return KIND_PACKAGE;
int len = 0;
int kind = 0;
switch (name[3])
{
// we look at the fourth character --------v
case 'm': len = 4; kind = KIND_ATOM; break; // atom
case 'g': len = 8; kind = KIND_LANGUAGE; break; // language
case 's': len = 7; kind = KIND_MESSAGE; break; // message
case 'c': len = 5; kind = KIND_PATCH; break; // patch
case 't': len = 7; kind = KIND_PATTERN; break; // pattern
case 'd': len = 7; kind = KIND_PRODUCT; break; // product
case 'e': len = 9; kind = KIND_SELECTION; break; // selection
case 'i': len = 6; kind = KIND_SCRIPT; break; // script
default:
return KIND_PACKAGE;
}
int i;
// make sure string doesn't end before the position of the ':'
for (i = 4; i < len && name[i]; i++)
;
if (i == len && name[i] == ':')
return kind;
return KIND_PACKAGE;
}
This needs to touch just one cache line of something which most probably
is in cache already (the name) and hence is only slower by a couple of
cycles compared to directly having the kind stored away. But it saves
half the size of Solvables.
Ciao,
Michael.
--
To unsubscribe, e-mail: zypp-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-devel+help@xxxxxxxxxxxx
On Tue, 18 Dec 2007, mlandres@xxxxxxxxxxxxxxxx wrote:
Author: mlandres
Date: Tue Dec 18 21:49:35 2007
New Revision: 8127
URL: http://svn.opensuse.org/viewcvs/zypp?rev=8127&view=rev
Log:
- Changed ResKind implementation to use IdStr.
- split Solvable ident into kind/name
- map src/nosrc Solvables to kind(SrcPackage) and arch(noarch)
I think it would be better if either libzypp would do away with the
Solvable kind altogether, or implement this so that it doesn't take up any
space in the libzypp wrapper of the sat Solvable structure.
I can't really see how fantastically usefull the kind is to deserve it
having an own member. The only uses I can imagine are of the type "give
me only Patches" or "don't search Patterns" and the like. The old solver
also uses them in Dependencies, but let's ignore that, as it's going away.
So, in all cases you already have a Solvable, hence the complete SAT Name,
which includes the "type". I think it would be better to compute the kind
from that whenever it's necessary, instead of storing it. It can be done
quite fast when we assume that ':' doesn't occur normally in a name (we
can assume that):
int solv2kind (Solvable *s)
{
if (s->arch == ARCH_SRC || s->arch == ARCH_NOSRC)
return KIND_SOURCEPACK;
const char *name = id2str(s->name);
// make sure we have four characters
if (!(name[0] && name[1] && name[2] && name[3]))
return KIND_PACKAGE;
int len = 0;
int kind = 0;
switch (name[3])
{
// we look at the fourth character --------v
case 'm': len = 4; kind = KIND_ATOM; break; // atom
case 'g': len = 8; kind = KIND_LANGUAGE; break; // language
case 's': len = 7; kind = KIND_MESSAGE; break; // message
case 'c': len = 5; kind = KIND_PATCH; break; // patch
case 't': len = 7; kind = KIND_PATTERN; break; // pattern
case 'd': len = 7; kind = KIND_PRODUCT; break; // product
case 'e': len = 9; kind = KIND_SELECTION; break; // selection
case 'i': len = 6; kind = KIND_SCRIPT; break; // script
default:
return KIND_PACKAGE;
}
int i;
// make sure string doesn't end before the position of the ':'
for (i = 4; i < len && name[i]; i++)
;
if (i == len && name[i] == ':')
return kind;
return KIND_PACKAGE;
}
This needs to touch just one cache line of something which most probably
is in cache already (the name) and hence is only slower by a couple of
cycles compared to directly having the kind stored away. But it saves
half the size of Solvables.
Ciao,
Michael.
--
To unsubscribe, e-mail: zypp-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-devel+help@xxxxxxxxxxxx
| < Previous | Next > |