- 1
- 2
std::bad_alloc e;
throw std::move(e);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−23
std::bad_alloc e;
throw std::move(e);
Написал один новичок. Говорит это особая сильно ускоряющая оптимизация.
−23
bool strictlyLess(std::vector<int> v1, std::vector<int>v2) { // v1 < v2
bool strictly = false;
for(int i = 0; i < v1.size(); i++) {
if(v1[i] > v2[i]) {
return false;
}
if(v1[i] < v2[i]) {
strictly = true;
}
}
return strictly;
}
+100
function Tf_MainFrame.DateToText(d: TDate; tp: integer): string;
var s: string;
g: integer;
begin
if DateToStr(d) = '00.00.0000' then
begin
result := '';
end else begin
case tp of
2:begin
s := ''; DateTimeToString(s,'dd',d);
result := s;
DateTimeToString(s,'mm',d);
g := StrToInt(s);
DateTimeToString(s,'yyyy',d);
case g of
1: begin result := result + ' января ' + s; end;
2: begin result := result + ' февраля ' + s; end;
3: begin result := result + ' марта ' + s; end;
4: begin result := result + ' апреля ' + s; end;
5: begin result := result + ' майя ' + s; end;
6: begin result := result + ' июня ' + s; end;
7: begin result := result + ' июля ' + s; end;
8: begin result := result + ' августа ' + s; end;
9: begin result := result + ' сентября ' + s; end;
10: begin result := result + ' октября ' + s; end;
11: begin result := result + ' ноября ' + s; end;
12: begin result := result + ' декабря ' + s; end;
end;
end
else begin
result := DateToStr(d);
end;
end;
end;
end;
Календарь ацтеков, месяц майя:)
+86
public static String serialize3(IModellingWorkerSetup r) {
return serialize(serialize(serialize(r)));
}
как вы понимаете, есть и обратное преобразование
+96
if (IsPostBack)
{
string PostBackerID = Request.Form.Get("__EVENTTARGET");
string PostBackerArg = Request.Form.Get("__EVENTARGUMENT");
if (PostBackerID == "ctl00$cphMainContent$pagerID")
{
CurrentReviewPage = int.Parse(PostBackerArg);
FillReviews();
}
else if (PostBackerID == "ctl00$cphMainContent$Like")
{
FillLike();
}
else if (PostBackerID == "ctl00$cphMainContent$review")
{
AddReview(PostBackerArg);
}
else if (PostBackerID == "ctl00$cphMainContent$Follow")
{
FillFollow();
}
else if (PostBackerID == "ctl00$cphMainContent$WebResultpagerID")
{
CurrentWebResultPage = int.Parse(PostBackerArg);
FillWebResults();
}
else if (PostBackerID == "ctl00$cphMainContent$WebResultCluster" || PostBackerID == "ctl00$cphMainContent$HiddenButton")
{
CurrentWebResultPage = 0;
int SelectedClusterID = int.Parse(PostBackerArg);
if (AllClusters != null && AllClusters.ContainsKey(SelectedClusterID))
{
SelectedClusterName = AllClusters[SelectedClusterID];
FillWebResults();
}
}
}
компактная логика всей страницы...
−22
// UNALIGNED only for IA64 (Itanium)
// for AMD64 & i386 this not needed
void * c_memmove(void *dest, void const *src, size_t n)
{
void *ret = dest;
if (n)
{
(__int8 *&)dest += n;
(__int8 *&)src += n;
switch (int x = n % 4)
{
do
{
if (!!'true')
{
case 0:
*--(UNALIGNED __int32 *&)dest = *--(UNALIGNED __int32 *&)src;
n -= 4;
}
else
{
case 3:
*--(__int8 *&)dest = *--(__int8 *&)src;
case 2:
*--(__int8 *&)dest = *--(__int8 *&)src;
case 1:
*--(__int8 *&)dest = *--(__int8 *&)src;
n -= x;
}
} while (n);
}
}
return ret;
}
+61
foreach($combinations as $combination){
$buffer = array();
if(count($combination)){
if(is_numeric($combination[0])){
$a_cnt = count($words[$combination[0]]);
for($a=0;$a<$a_cnt;$a++){
if(is_numeric($combination[1])){
$b_cnt = count($words[$combination[1]]);
for($b=0;$b<$b_cnt;$b++){
if(is_numeric($combination[2])){
$c_cnt = count($words[$combination[2]]);
for($c=0;$c<$c_cnt;$c++){
if(is_numeric($combination[3])){
$d_cnt = count($words[$combination[3]]);
for($d=0;$d<$d_cnt;$d++){
if(is_numeric($combination[4])){
$e_cnt = count($words[$combination[4]]);
for($e=0;$e<$e_cnt;$e++){
if(is_numeric($combination[5])){
$f_cnt = count($words[$combination[5]]);
for($f=0;$f<$f_cnt;$f++){
if(is_numeric($combination[6])){
$g_cnt = count($words[$combination[6]]);
for($g=0;$g<$g_cnt;$g++){
if(is_numeric($combination[7])){
$h_cnt = count($words[$combination[7]]);
for($h=0;$h<$h_cnt;$h++){
if(is_numeric($combination[8])){
$i_cnt = count($words[$combination[8]]);
for($i=0;$i<$i_cnt;$i++){
if(is_numeric($combination[9])){
$j_cnt = count($words[$combination[9]]);
for($j=0;$j<$j_cnt;$j++){
$buffer[] = $words[$combination[0]][$a]
.' '.$words[$combination[1]][$b]
.' '.$words[$combination[2]][$c]
.' '.$words[$combination[3]][$d]
.' '.$words[$combination[4]][$e]
.' '.$words[$combination[5]][$f]
.' '.$words[$combination[6]][$g]
.' '.$words[$combination[7]][$h]
.' '.$words[$combination[8]][$i]
.' '.$words[$combination[9]][$j];
}}
else{
$buffer[] = $words[$combination[0]][$a]
.' '.$words[$combination[1]][$b]
.' '.$words[$combination[2]][$c]
.' '.$words[$combination[3]][$d]
.' '.$words[$combination[4]][$e]
.' '.$words[$combination[5]][$f]
.' '.$words[$combination[6]][$g]
.' '.$words[$combination[7]][$h]
.' '.$words[$combination[8]][$i];
}
}}
else{
$buffer[] = $words[$combination[0]][$a]
.' '.$words[$combination[1]][$b]
.' '.$words[$combination[2]][$c]
.' '.$words[$combination[3]][$d]
.' '.$words[$combination[4]][$e]
.' '.$words[$combination[5]][$f]
.' '.$words[$combination[6]][$g]
.' '.$words[$combination[7]][$h];
}
}}
else{
$buffer[] = $words[$combination[0]][$a]
.' '.$words[$combination[1]][$b]
.' '.$words[$combination[2]][$c]
.' '.$words[$combination[3]][$d]
.' '.$words[$combination[4]][$e]
.' '.$words[$combination[5]][$f]
.' '.$words[$combination[6]][$g];
}
}}
else{
$buffer[] = $words[$combination[0]][$a]
.' '.$words[$combination[1]][$b]
.' '.$words[$combination[2]][$c]
.' '.$words[$combination[3]][$d]
.' '.$words[$combination[4]][$e]
.' '.$words[$combination[5]][$f];
}
}}
else{
$buffer[] = $words[$combination[0]][$a]
.' '.$words[$combination[1]][$b]
.' '.$words[$combination[2]][$c]
.' '.$words[$combination[3]][$d]
.' '.$words[$combination[4]][$e];
}
}}
else{
$buffer[] = $words[$combination[0]][$a]
.' '.$words[$combination[1]][$b]
.' '.$words[$combination[2]][$c]
.' '.$words[$combination[3]][$d];
}
Вот такой вот кусок кода, к стати весь не поместился, я нашел в самописном движке, на котором моему знакомому сделали корпоративный сайт на 30 страниц. Бюджет был больше 2к зелени.
−88
NSString *error = [NSString stringWithFormat:@"Enter your %@%@%@",
[email length] ? @"" : @"email",
[email length] || [password length] ? @"" : @" and ",
[password length] ? @"" : @"password"];
Дай дураку тернарный оператор - он и лоб расшибет.
−151
private function chopCompleteHandler(e : DataEvent):void
{
if (e.getData().toString() != "false")//что за чудесные преобразования? ////так надо, по другому не хочет
{
_player.animLift();
if (!e.getData().energy)
{
targetSquare.fieldObject.lifes = uint(e.getData().lifes);
if (e.getData().lifes == 0)
targetSquare.destroyFieldObject();
if (e.getData().bonus)
scatterBunuses(e.getData().bonus);
Model.instance.requestData(ModelEnum.SERVICE_USER, ModelEnum.METHOD_GETINFO, true, GameCanvas.instance.userID);
}
else
Alert.show("Нужно еще " + e.getData().energy+".", "Недостаточно энергии");
}
}
+78
/*при всем этом работает как часы*/
...
foreach ($array as $k=>$v) {
$k++
if ($k==300) {
die ('выходим потому что 5');
}
...
маленькая часть большого парсера